- added to FunctionBase: bool register_default_models (default true)
if true then winix will add default models for ezc templates such as "request", "item", etc. - some methods from templates/item.cpp moved to Item
This commit is contained in:
@@ -344,6 +344,7 @@ bool App::Init()
|
||||
model_connector.set_winix_locale(&TemplatesFunctions::locale);
|
||||
model_connector.set_winix_session_manager(&session_manager);
|
||||
model_connector.set_winix_time_zones(&system.time_zones);
|
||||
model_connector.set_winix_pattern_cacher(&TemplatesFunctions::pattern_cacher);
|
||||
|
||||
if( !TryToMakeDatabaseMigration() )
|
||||
return false;
|
||||
@@ -846,6 +847,24 @@ void App::CheckPostRedirect()
|
||||
}
|
||||
|
||||
|
||||
void App::AddDefaultModels()
|
||||
{
|
||||
if( !cur.request->send_bin_stream && !cur.request->return_json )
|
||||
{
|
||||
if( cur.request->function && cur.request->function->register_default_models )
|
||||
{
|
||||
cur.request->models.Add(L"request", cur.request);
|
||||
|
||||
if( cur.request->is_item )
|
||||
{
|
||||
cur.request->models.Add(L"item", cur.request->item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// !! IMPROVE ME change to a better name
|
||||
// may ProcessRequest()? but probably it is already defined...
|
||||
// this method needs some refactoring
|
||||
@@ -886,6 +905,8 @@ void App::Make()
|
||||
if( !cur.request->redirect_to.empty() )
|
||||
return;
|
||||
|
||||
AddDefaultModels();
|
||||
|
||||
if( cur.request->status == WINIX_ERR_OK )
|
||||
functions.MakeFunction();
|
||||
|
||||
|
Reference in New Issue
Block a user