added: to config:

parameter: ezc_max_elements
          maximum number for elements through the whole template (ezc)
          default: 50000
       parameter: ezc_max_loop_elements
          maximum number of each [for] loop
          default: 5000 (from ezc generator)
added: to Request class:
       time_t start_time;
       tm start_tm;
       they are set when a request starts
       


git-svn-id: svn://ttmath.org/publicrep/winix/trunk@806 e52654a7-88a9-db11-a3e9-0013d4bc506e
pull/3/head
Tomasz Sowa 11 years ago
parent 9d2be5c50d
commit 1a51b1adc7

@ -265,6 +265,7 @@ void App::ProcessRequest()
{
try
{
cur.request->RequestStarts();
system.load_avg.StartRequest();
log << log2 << config.log_delimiter << logend;

@ -230,6 +230,10 @@ void Config::AssignValues(bool stdout_is_closed)
content_type_header = Int(L"content_type_header", 0);
umask = Int(L"umask", 0222);
ezc_max_elements = Size(L"ezc_max_elements", 50000);
ezc_max_loop_elements = Size(L"ezc_max_loop_elements", 5000);
}

@ -459,6 +459,16 @@ public:
int umask;
// maximum number for elements through the whole template
// default: 50000
size_t ezc_max_elements;
// maximum number of each [for] loop
// default: 5000 (from ezc generator)
size_t ezc_max_loop_elements;
Config();
bool ReadConfig(bool errors_to_stdout_, bool stdout_is_closed = true);

@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2010-2011, Tomasz Sowa
* Copyright (c) 2010-2012, Tomasz Sowa
* All rights reserved.
*
*/
@ -19,6 +19,10 @@ Item::Item()
}
// !! IMPROVE ME
// now we have Request::start_time and Request::start_tm
// we can somehow get the current time from the request
// may setting the date should be completetly removed from here?
void Item::SetDateToNow()
{
date_creation = Time(std::time(0));

@ -84,10 +84,23 @@ void Request::Clear()
send_as_attachment = false;
using_ssl = false;
start_time = 0;
memset(&start_tm, 0, sizeof(start_tm));
}
void Request::RequestStarts()
{
// clearing it is better to use at the end of a request
// so starting is much faster
start_time = std::time(0);
start_tm = Time(start_time);
}
// value can be null
void Request::SetCookie(const char * name, const char * value, tm * expires)

@ -130,12 +130,18 @@ struct Request
// this is a pointer either to the item (if exists) or to the last directory
Item * last_item;
// request start time
// Time() methods are very slow so it is better to directly use those two values
// they are set when a request starts
time_t start_time;
tm start_tm;
Request();
void SetConfig(Config * pconfig);
void RequestStarts();
void Clear();
bool IsParam(const wchar_t * param_name);

@ -519,6 +519,12 @@ logout.o: ../templates/htmltextstream.h ../core/mounts.h
logout.o: ../core/mountparser.h ../core/crypt.h ../core/users.h
logout.o: ../core/groups.h ../core/group.h ../core/loadavg.h ../core/image.h
logout.o: ../core/basethread.h ../core/threadmanager.h ../core/synchro.h
logout.o: ../core/plugin.h ../core/pluginmsg.h ../core/system.h
logout.o: ../core/sessionmanager.h ../core/sessioncontainer.h
logout.o: ../functions/functions.h ../templates/templates.h
logout.o: ../templates/patterncacher.h ../templates/indexpatterns.h
logout.o: ../templates/patterns.h ../templates/changepatterns.h
logout.o: ../core/sessionmanager.h
ls.o: ls.h functionbase.h ../core/item.h ../db/db.h ../db/dbbase.h
ls.o: ../db/dbconn.h ../db/dbtextstream.h ../core/textstream.h ../core/misc.h
ls.o: ../core/item.h ../core/requesttypes.h ../core/error.h

@ -331,6 +331,7 @@ void thread_sort_tab_run(Info & i)
Ezc::Pattern * p = pattern_cacher.GetPattern(*thread_info.item_sort_tab[item_sort_index]);
item_run_content.Clear();
ezc_generator.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
ezc_generator.Generate(item_run_content, *p);
item_print_content(i.out, item_run_content.Str(), thread_info.item_sort_tab[item_sort_index]->content_type);

@ -45,6 +45,7 @@ void insert_page_run(Info & i)
insert_page_cur += 1;
info.run_content.Clear();
info.ezc_gen.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
info.ezc_gen.Generate(info.run_content, *pat);
item_print_content(i.out, info.run_content.Str(), info.item.content_type);

@ -292,6 +292,7 @@ void item_run(Info & i)
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item);
item_run_content.Clear();
ezc_generator.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
ezc_generator.Generate(item_run_content, *p);
item_print_content(i.out, item_run_content.Str(), cur->request->item.content_type);
@ -652,6 +653,7 @@ void item_tab_run(Info & i)
{
Ezc::Pattern * p = pattern_cacher.GetPattern(cur->request->item_tab[item_index]);
item_run_content.Clear();
ezc_generator.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
ezc_generator.Generate(item_run_content, *p);
item_print_content(i.out, item_run_content.Str(), cur->request->item_tab[item_index].content_type);
}

@ -122,9 +122,14 @@ Ezc::Pattern * p = 0;
if( p )
{
content_gen.SetMax(config->ezc_max_elements, config->ezc_max_loop_elements);
content_gen.Generate(i.out, *p);
}
else
{
log << log1 << "Templates: content: there are not any patterns";
}
}

Loading…
Cancel
Save