summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-07-01 20:13:49 +0000
committerrandomdan <randomdan@localhost>2010-07-01 20:13:49 +0000
commit1ef65c27b67627aaaf04a16dad476cdddd48a1d8 (patch)
treeff4bb523e16f780cbf1b24cc6ba1dfe3d608bc5b
parentInclude session contents in results (diff)
downloadproject2-1ef65c27b67627aaaf04a16dad476cdddd48a1d8.tar.bz2
project2-1ef65c27b67627aaaf04a16dad476cdddd48a1d8.tar.xz
project2-1ef65c27b67627aaaf04a16dad476cdddd48a1d8.zip
Keep the source DOM tree in memory and use it to implement rawview
-rw-r--r--project2/cgiAppEngine.cpp6
-rw-r--r--project2/cgiAppEngine.h2
-rw-r--r--project2/p2webMain.cpp1
-rw-r--r--project2/rawView.cpp28
-rw-r--r--project2/rawView.h24
-rw-r--r--project2/sessionClearTask.cpp3
-rw-r--r--project2/view.cpp2
7 files changed, 62 insertions, 4 deletions
diff --git a/project2/cgiAppEngine.cpp b/project2/cgiAppEngine.cpp
index d3fbe80..60b1ed3 100644
--- a/project2/cgiAppEngine.cpp
+++ b/project2/cgiAppEngine.cpp
@@ -3,7 +3,6 @@
#include <cgicc/Cgicc.h>
#include <cgicc/HTTPContentHeader.h>
#include "cgiEnvironment.h"
-#include <libxml++/parsers/domparser.h>
#include <libxml/xinclude.h>
#include "xmlObjectLoader.h"
#include "rdbmsDataSource.h"
@@ -71,9 +70,10 @@ CgiApplicationEngine::Stage::~Stage()
{
}
-CgiApplicationEngine::PresentStage::PresentStage(const CgiApplicationEngine * e, const std::string & id) : CgiApplicationEngine::Stage(e)
+CgiApplicationEngine::PresentStage::PresentStage(const CgiApplicationEngine * e, const std::string & id) :
+ CgiApplicationEngine::Stage(e),
+ present("present/" + id + ".xml")
{
- xmlpp::DomParser present("present/" + id + ".xml");
while (xmlXIncludeProcessFlags(present.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0);
xmlpp::Element * presentRoot = present.get_document()->get_root_node();
responseRootNodeName = presentRoot->get_attribute_value("root");
diff --git a/project2/cgiAppEngine.h b/project2/cgiAppEngine.h
index 9532ed4..f6f37d0 100644
--- a/project2/cgiAppEngine.h
+++ b/project2/cgiAppEngine.h
@@ -7,6 +7,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/uuid/uuid.hpp>
#include <libxml++/document.h>
+#include <libxml++/parsers/domparser.h>
class CgiEnvironment;
namespace cgicc {
@@ -59,6 +60,7 @@ class CgiApplicationEngine : public ApplicationEngine {
Views views;
Glib::ustring responseRootNodeName;
Glib::ustring responseStyle;
+ xmlpp::DomParser present;
};
mutable Stage * currentStage;
mutable boost::uuids::uuid sessionID;
diff --git a/project2/p2webMain.cpp b/project2/p2webMain.cpp
index f424e0a..a526f8d 100644
--- a/project2/p2webMain.cpp
+++ b/project2/p2webMain.cpp
@@ -33,6 +33,7 @@ int main(void)
cgicc::HTTPContentHeader header("text/xml-xslt");
CgiApplicationEngine app(&env, &header);
app.process();
+ IO << "Cache-control: no-cache" << std::endl;
header.render(IO);
xmlOutputBufferPtr out = xmlOutputBufferCreateIO(
xmlWrite, NULL, &IO, xmlGetCharEncodingHandler(XML_CHAR_ENCODING_UTF8));
diff --git a/project2/rawView.cpp b/project2/rawView.cpp
new file mode 100644
index 0000000..1b79815
--- /dev/null
+++ b/project2/rawView.cpp
@@ -0,0 +1,28 @@
+#include <syslog.h>
+#include "rawView.h"
+#include "xml.h"
+#include "xmlObjectLoader.h"
+#include "environment.h"
+#include "appEngine.h"
+
+_RawView::_RawView(const xmlpp::Element * p) :
+ _SourceObject(p),
+ _View(p),
+ copyRoot(p)
+{
+}
+
+Glib::ustring
+_RawView::getCurrentValue(const Glib::ustring & id) const
+{
+ return "";
+}
+
+void _RawView::execute(xmlpp::Element * par, const ApplicationEngine * ep, const _View * parent) const
+{
+ BOOST_FOREACH(xmlpp::Node * node, copyRoot->get_children()) {
+ par->import_node(node);
+ }
+}
+
+
diff --git a/project2/rawView.h b/project2/rawView.h
new file mode 100644
index 0000000..8d069b0
--- /dev/null
+++ b/project2/rawView.h
@@ -0,0 +1,24 @@
+#ifndef RAWVIEW_H
+#define RAWVIEW_H
+
+#include <libxml++/nodes/element.h>
+#include <boost/shared_ptr.hpp>
+#include <map>
+#include "view.h"
+
+class ApplicationEngine;
+
+class _RawView : public _View {
+ public:
+ _RawView(const xmlpp::Element * p);
+ void execute(xmlpp::Element *, const ApplicationEngine *, const _View * parent = NULL) const;
+ Glib::ustring getCurrentValue(const Glib::ustring & id) const;
+ private:
+ const xmlpp::Element * copyRoot;
+};
+typedef boost::shared_ptr<_RawView> RawView;
+typedef std::map<std::string, RawView> RawViews;
+
+#endif
+
+
diff --git a/project2/sessionClearTask.cpp b/project2/sessionClearTask.cpp
index c5d6d0d..963ebeb 100644
--- a/project2/sessionClearTask.cpp
+++ b/project2/sessionClearTask.cpp
@@ -5,7 +5,8 @@
_SessionClearTask::_SessionClearTask(const xmlpp::Element * p) :
_SourceObject(p),
- _Task(p)
+ _Task(p),
+ key(p->get_attribute_value("key"))
{
}
diff --git a/project2/view.cpp b/project2/view.cpp
index 799d1ae..c36c43d 100644
--- a/project2/view.cpp
+++ b/project2/view.cpp
@@ -2,6 +2,7 @@
#include <boost/foreach.hpp>
#include "xmlObjectLoader.h"
#include "sqlView.h"
+#include "rawView.h"
_View::_View(const xmlpp::Element * p) :
_SourceObject(p),
@@ -17,6 +18,7 @@ void
_View::AddLoaders(Loaders & l, Views & views)
{
l.insert(LoadersVT("sqlview", _LoaderBase::Make<_SqlView, _View, std::string, _SourceObject, &_SourceObject::name>(&views)));
+ l.insert(LoadersVT("rawview", _LoaderBase::Make<_RawView, _View, std::string, _SourceObject, &_SourceObject::name>(&views)));
}
void