diff --git a/winixd/functions/cat.cpp b/winixd/functions/cat.cpp
index 3fd37be..6d22c3e 100644
--- a/winixd/functions/cat.cpp
+++ b/winixd/functions/cat.cpp
@@ -34,7 +34,6 @@
#include "cat.h"
-
namespace Winix
{
@@ -68,6 +67,23 @@ void Cat::MakeGet()
}
cur->request->send_as_attachment = cur->request->IsParam(L"attachment");
+
+
+ // temporary for tests
+ ////////////////////////////////////////////////////////////
+ foo1.subject = L"subject
from
foo1";
+ foo2.subject = L"subject from foo2";
+
+ foo1.item_content.content_raw = L"raw content from foo1";
+ foo2.item_content.content_raw = L"raw content from foo2";
+
+ foo1.set_connector(model_connector);
+ foo2.set_connector(model_connector);
+
+ return_model(L"foo1", foo1);
+ return_model(L"foo2", foo2);
+ ////////////////////////////////////////////////////////////
+
}
diff --git a/winixd/functions/cat.h b/winixd/functions/cat.h
index 0302490..8194f0e 100644
--- a/winixd/functions/cat.h
+++ b/winixd/functions/cat.h
@@ -37,6 +37,7 @@
#include "functionbase.h"
+
namespace Winix
{
@@ -52,6 +53,12 @@ public:
Cat();
void MakeGet();
+
+private:
+
+ Item foo1;
+ Item foo2;
+
};
diff --git a/winixd/functions/functionbase.cpp b/winixd/functions/functionbase.cpp
index b4e3ad1..f1514a9 100644
--- a/winixd/functions/functionbase.cpp
+++ b/winixd/functions/functionbase.cpp
@@ -34,6 +34,7 @@
#include "functionbase.h"
#include "functions.h"
+#include "templates/templates.h"
namespace Winix
@@ -148,6 +149,18 @@ void FunctionBase::MakeDelete()
+void FunctionBase::return_model(const wchar_t * name, morm::Model & model)
+{
+ TemplatesFunctions::ezc_models.Add(name, model);
+}
+
+void FunctionBase::return_model(const wchar_t * name, morm::Model * model)
+{
+ TemplatesFunctions::ezc_models.Add(name, model);
+}
+
+
+
} // namespace Winix
diff --git a/winixd/functions/functionbase.h b/winixd/functions/functionbase.h
index 53662a6..447c2d0 100644
--- a/winixd/functions/functionbase.h
+++ b/winixd/functions/functionbase.h
@@ -101,6 +101,10 @@ public:
//void SetSynchro(Synchro * psynchro);
//void SetSessionManager(SessionManager * pmanager);
+
+ virtual void return_model(const wchar_t * name, morm::Model & model);
+ virtual void return_model(const wchar_t * name, morm::Model * model);
+
protected:
//Config * config;
diff --git a/winixd/models/item.cpp b/winixd/models/item.cpp
index c812c9d..ff61d0b 100644
--- a/winixd/models/item.cpp
+++ b/winixd/models/item.cpp
@@ -63,7 +63,9 @@ void Item::fields()
field(L"subject", subject);
field(L"template", html_template);
field(L"sort_index", sort_index);
- field(L"content_id", item_content, morm::FT::foreign_key);
+ field(L"content_id", L"content", item_content, morm::FT::foreign_key);
+
+ //field(L"my_test_function", my_test_function);
// may we should add a method setTypeFromInt(int t)?
type = static_cast(type_helper);
diff --git a/winixd/models/item.h b/winixd/models/item.h
index 9545837..0c001ff 100644
--- a/winixd/models/item.h
+++ b/winixd/models/item.h
@@ -44,6 +44,10 @@
#include "core/log.h"
+#include "funinfo.h"
+#include "templates/htmltextstream.h"
+
+
namespace Winix
{
@@ -180,6 +184,12 @@ public:
void propagate_connector();
+ // for tests
+ static void my_test_function(Ezc::FunInfo & env)
+ {
+ env.out << L"hello from function";
+ }
+
protected:
diff --git a/winixd/templates/misc.cpp b/winixd/templates/misc.cpp
index ac06032..7422fa5 100644
--- a/winixd/templates/misc.cpp
+++ b/winixd/templates/misc.cpp
@@ -48,6 +48,7 @@ namespace TemplatesFunctions
extern EzcFun ezc_functions;
extern Ezc::Blocks ezc_blocks;
extern Ezc::Vars ezc_vars;
+extern Ezc::Models ezc_models;
void HtmlEscapeFormTxt(HtmlTextStream & out, const std::wstring & in)
@@ -108,6 +109,8 @@ void InitGenerator(EzcGen & gen)
gen.SetBlocks(ezc_blocks);
gen.SetFunctions(ezc_functions);
gen.SetVariables(ezc_vars);
+
+ gen.SetModels(ezc_models);
}
diff --git a/winixd/templates/templates.cpp b/winixd/templates/templates.cpp
index 87c1130..9205125 100644
--- a/winixd/templates/templates.cpp
+++ b/winixd/templates/templates.cpp
@@ -63,6 +63,7 @@ EzcFun ezc_functions;
Ezc::Blocks ezc_blocks;
Ezc::Objects ezc_objects;
Ezc::Vars ezc_vars;
+Ezc::Models ezc_models;
LocaleFilter locale_filter;
HTMLFilter html_filter;
@@ -1022,7 +1023,9 @@ void Templates::ClearAfterRequest()
using namespace TemplatesFunctions;
log << log4 << "Templates: patterns cache size: " << pattern_cacher.Size() << logend;
- pattern_cacher.DeleteOldPatterns();
+ pattern_cacher.DeleteOldPatterns();
+
+ ezc_models.Clear();
}
diff --git a/winixd/templates/templates.h b/winixd/templates/templates.h
index 27744c8..ad5448a 100644
--- a/winixd/templates/templates.h
+++ b/winixd/templates/templates.h
@@ -96,6 +96,7 @@ namespace TemplatesFunctions
extern bool gen_skip_new_line;
extern bool gen_use_special_chars;
+ extern Ezc::Models ezc_models;