cppcms-users Mailing List for CppCMS C++ Web Framework (Page 87)
Brought to you by:
artyom-beilis
You can subscribe to this list here.
2009 |
Jan
|
Feb
(22) |
Mar
|
Apr
(3) |
May
|
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(15) |
Nov
(16) |
Dec
(13) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2010 |
Jan
(4) |
Feb
|
Mar
(8) |
Apr
(8) |
May
(8) |
Jun
(36) |
Jul
(63) |
Aug
(126) |
Sep
(47) |
Oct
(66) |
Nov
(46) |
Dec
(42) |
2011 |
Jan
(87) |
Feb
(24) |
Mar
(54) |
Apr
(21) |
May
(22) |
Jun
(18) |
Jul
(22) |
Aug
(101) |
Sep
(57) |
Oct
(33) |
Nov
(34) |
Dec
(66) |
2012 |
Jan
(64) |
Feb
(76) |
Mar
(73) |
Apr
(105) |
May
(93) |
Jun
(83) |
Jul
(84) |
Aug
(88) |
Sep
(57) |
Oct
(59) |
Nov
(35) |
Dec
(49) |
2013 |
Jan
(67) |
Feb
(17) |
Mar
(49) |
Apr
(64) |
May
(87) |
Jun
(64) |
Jul
(93) |
Aug
(23) |
Sep
(15) |
Oct
(16) |
Nov
(62) |
Dec
(73) |
2014 |
Jan
(5) |
Feb
(23) |
Mar
(21) |
Apr
(11) |
May
(1) |
Jun
(19) |
Jul
(27) |
Aug
(16) |
Sep
(5) |
Oct
(37) |
Nov
(12) |
Dec
(9) |
2015 |
Jan
(7) |
Feb
(7) |
Mar
(44) |
Apr
(28) |
May
(5) |
Jun
(12) |
Jul
(8) |
Aug
|
Sep
(39) |
Oct
(34) |
Nov
(30) |
Dec
(34) |
2016 |
Jan
(66) |
Feb
(23) |
Mar
(33) |
Apr
(15) |
May
(11) |
Jun
(15) |
Jul
(26) |
Aug
(4) |
Sep
(1) |
Oct
(30) |
Nov
(10) |
Dec
|
2017 |
Jan
(52) |
Feb
(9) |
Mar
(24) |
Apr
(16) |
May
(9) |
Jun
(12) |
Jul
(33) |
Aug
(8) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
(6) |
2018 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
(14) |
Jun
(1) |
Jul
(9) |
Aug
(1) |
Sep
(13) |
Oct
(8) |
Nov
(2) |
Dec
(2) |
2019 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
2020 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(9) |
Jul
(6) |
Aug
(25) |
Sep
(10) |
Oct
(10) |
Nov
(6) |
Dec
|
2021 |
Jan
|
Feb
|
Mar
(7) |
Apr
(1) |
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
(9) |
Oct
(1) |
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ele...@ex...> - 2012-05-07 08:47:38
|
>> In this case do I have to store all the variables on the function stack >> before passing them to statement? > if you have your elements in a vector/array/json::array(is a vector > itself) you can do this: > http://cppcms.com/sql/cppdb/stat.html#stat_reset This actually brings up another question about transactions. I understand transactions work this way - cppdb::transaction tr(sql) sql << "INSERT INTO ......" << cppdb::exec sql << "INSERT INTO ......" << cppdb::exec tr.commit() What if you can't use the syntatic sugar but have to deal with statements directly? Ive tried cppdb::transaction tr(sql) cppdb::statement st = sql.prepare("..."); st.bind(...) st.bind(...) st.exec() cppdb::statement st2 = sql.prepare("...") st.bind(...) st.exec() tr.commit() This throws an exception saying sqlite3:cannot rollback transaction - SQL statements in progress What's the proper way? |
From: Marcel H. <ke...@co...> - 2012-05-07 08:02:37
|
Am 07.05.2012 09:57, schrieb ele...@ex...: > > sql<< "INSERT ..."<< ...<< r.get<string>("date_action"))<< ...<< >> cppdb::exec; >> >> This would be valid as the return value remains withing the statement. >> >> Artyom Beilis. > I understand that however what if you need to do something like this - > > cppdb::statement st; > st = sql.prepare(...) > > st<< one<< two; > > if (condition is true) > st<< three<< four > else > st<< five<< six > end > > st.exec() > > In this case do I have to store all the variables on the function stack > before passing them to statement? if you have your elements in a vector/array/json::array(is a vector itself) you can do this: http://cppcms.com/sql/cppdb/stat.html#stat_reset > Petr > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: <ele...@ex...> - 2012-05-07 07:57:43
|
> sql << "INSERT ..." << ... << r.get<string>("date_action")) << ... << > cppdb::exec; > > This would be valid as the return value remains withing the statement. > > Artyom Beilis. I understand that however what if you need to do something like this - cppdb::statement st; st = sql.prepare(...) st << one << two; if (condition is true) st << three << four else st << five << six end st.exec() In this case do I have to store all the variables on the function stack before passing them to statement? Petr |
From: Artyom B. <art...@ya...> - 2012-05-07 06:37:40
|
----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > > I was trying to figure out why > > st.prepare(....) > .... > st.bind(5, r.get<string>("date_action")); > .... > st.exec() > > in my code produces unpredictable behaviour untill I read in the > documentation that - > > Note: the reference to the string MUST remain valid until the statement is > queried or executed! > > [ snip ] > > Should statement::bind be using value instead of reference semantics? > No, this is a very important performance optimization. Consider the string of size of 50k - like article or some other data. Copying `std::string` would require both memory allocation and memory copy. More than that when you work with multiple strings each such copy semantics triggers a memory allocation that costs a lot, at least with C++11 string semantics were Copy-On-Write is forbidden. That is why you should keep the reference valid. BTW: You can do all this in one line sql << "INSERT ..." << ... << r.get<string>("date_action")) << ... << cppdb::exec; This would be valid as the return value remains withing the statement. Artyom Beilis. |
From: <ele...@ex...> - 2012-05-07 06:28:05
|
I was trying to figure out why st.prepare(....) .... st.bind(5, r.get<string>("date_action")); .... st.exec() in my code produces unpredictable behaviour untill I read in the documentation that - Note: the reference to the string MUST remain valid until the statement is queried or executed! In my code im copying some old rows into new rows and r.get<string>("date_action") returns the letter "R" but after it got binded to the new statement it was showing "l" which puzzled me to no-end as to why, but if I did string wtf = r.get<string>("date_action"); st.bind(5, wtf); it worked fine. Should statement::bind be using value instead of reference semantics? Petr |
From: Artyom B. <art...@ya...> - 2012-05-03 11:01:58
|
----- Original Message ----- > > Hi everyone, > Hi, > my last idea was to extend the thread pool and have some questions about it. > > As far as I know, async methods should not run too long, because they > block the entire service loop, right?! > Exactly > Also i have some other questions: > > At first: Could i "avoid" the thread pool and create a std::thread > instead? (Maybe i can give the thread pool a reference the thread object) > Of course you can. But: 1. Creation of a new thread is heavy procedure, it is much better and faster to submit a job to a pool 2. If you create too many threads it may cost a lot, thread pool would just enqueue the job that would be executed at some point, of the pool is too busy. 3. The size of the CppCMS's thread pool is optimized for run-time hardware concurrency So it is your choice :-) > Second: Would it be possible to give a std::function object to the > thread_pool? Yes, http://cppcms.com/cppcms_ref/latest/classcppcms_1_1thread__pool.html thread_pool::post receives a booster::function - the template object that can be created from any function-like object, including std::function. > > Third: What about callbacks? If a thread is finished you could define a > callback where you can define further operations (like evaluating the > result of the thread) > When the result of the thread is ready, post a job (some other callback) to the event loop using booster::aio::io_service::post. It would allow you to handle completion of the job in the pool. This post method receives generic callback as well. > Regards > > Marcel > Best, Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: Marcel H. <ke...@co...> - 2012-05-03 10:22:46
|
Hi everyone, my last idea was to extend the thread pool and have some questions about it. As far as I know, async methods should not run too long, because they block the entire service loop, right?! Also i have some other questions: At first: Could i "avoid" the thread pool and create a std::thread instead? (Maybe i can give the thread pool a reference the thread object) Second: Would it be possible to give a std::function object to the thread_pool? Third: What about callbacks? If a thread is finished you could define a callback where you can define further operations (like evaluating the result of the thread) Regards Marcel |
From: Artyom B. <art...@ya...> - 2012-05-02 19:23:52
|
In order to get a trace the exception that is thrown should be derived from booster::runtime_error class. CppDB is independent library that does not share the stack trace code with CppCMS, that is why you can't get a backtrace from CppDB. It is not supported. Also I'd recommend to use latest trunk, it has better support for backtracing (not based on execinfo) that works on BSD and Mac OS X as well Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ ----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > To: Artyom Beilis <art...@ya...>; cpp...@li... > Cc: > Sent: Wednesday, May 2, 2012 5:00 AM > Subject: Re: [Cppcms-users] Advice on debugging file upload > > Hi Artyom, > > Ive recompiled booster with your patch, but im still not getting a trace > when cppcms/cppdb throws - such as > > 2012-05-02 11:52:57; cppcms, error: Caught exception > [cppdb::invalid_column attempt access to invalid column] > (http_context.cpp:139 > > I would have assumed that it will show me trace so I can find out which > line tries to access the invalid column. > >> g++ -dynamic -O0 lib/backtrace/test/test_backtrace.cpp -L/usr/local/lib > -lbooster -I/usr/local/include >> ./a.out > My Error > 0x403270: booster::runtime_error::runtime_error(std::string const&) + 0x30 > in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out > 0x401cf2: _init + 0x60a in > /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out > 0x401da9: _init + 0x6c1 in > /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out > 0x401dbe: _init + 0x6d6 in > /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out > 0x4019fe: _init + 0x316 in > /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out > > > Petr > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: <ele...@ex...> - 2012-05-02 18:42:36
|
Hi Artyom, Ive recompiled booster with your patch, but im still not getting a trace when cppcms/cppdb throws - such as 2012-05-02 11:52:57; cppcms, error: Caught exception [cppdb::invalid_column attempt access to invalid column] (http_context.cpp:139 I would have assumed that it will show me trace so I can find out which line tries to access the invalid column. > g++ -dynamic -O0 lib/backtrace/test/test_backtrace.cpp -L/usr/local/lib -lbooster -I/usr/local/include > ./a.out My Error 0x403270: booster::runtime_error::runtime_error(std::string const&) + 0x30 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401cf2: _init + 0x60a in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401da9: _init + 0x6c1 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401dbe: _init + 0x6d6 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x4019fe: _init + 0x316 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out Petr |
From: <ele...@ex...> - 2012-05-02 02:00:37
|
Hi Artyom, Ive recompiled booster with your patch, but im still not getting a trace when cppcms/cppdb throws - such as 2012-05-02 11:52:57; cppcms, error: Caught exception [cppdb::invalid_column attempt access to invalid column] (http_context.cpp:139 I would have assumed that it will show me trace so I can find out which line tries to access the invalid column. > g++ -dynamic -O0 lib/backtrace/test/test_backtrace.cpp -L/usr/local/lib -lbooster -I/usr/local/include > ./a.out My Error 0x403270: booster::runtime_error::runtime_error(std::string const&) + 0x30 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401cf2: _init + 0x60a in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401da9: _init + 0x6c1 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x401dbe: _init + 0x6d6 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out 0x4019fe: _init + 0x316 in /usr/home/petr/Downloads/cppcms-1.0.0/booster/a.out Petr |
From: Artyom B. <art...@ya...> - 2012-04-30 07:10:42
|
Hi There is full support of colum names But you should refer to your engine documentation to see what the actual name is: In general the drivers use following API: sqlite3: sqlite3_column_name postgresql: PQfnumber mysql: mysql_fetch_fields odbc: SQLDescribeCol So if you do not get expected result you can debug it by converting column indexes to names and see what names are actually in use. cppdb::result::name would give you then names and then see what is wrong. In general using column names is much slower then using index, as it requires name - to index lookup. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: "ke...@co..." <ke...@co...> >To: cpp...@li... >Sent: Monday, April 30, 2012 9:40 AM >Subject: Re: [Cppcms-users] cppdb::result::get problem > > >At first. Never use select * >http://stackoverflow.com/questions/1433971/select-from-table-or-select-id-field1-field2-field3-from-table-best-practi >If you solve that problem then you can access them via integer index. > >The other one. Good question. Maybe artyom can say something about it. >-- >Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. > > > > >ele...@ex... schrieb: >Hello, >> >>Supposing I have a SELECT * FROM sometable st LEFT OUTER JOIN othertable >>ot ON (st.ot_id=ot.id) ... >> >>Then looping through the results using result::next() >> >>Why can't I access the results this way? >> >>r.get<string>("st.columnA") ? >> >>Imagine you want to get all the columns from both tables and some have >>duplicate column names such as - id or name >> >>Petr >> >> >>>>________________________________ >> >>Live Security Virtual Conference >>Exclusive live event will cover all the ways today's security and >>threat landscape has changed and how IT managers can respond. Discussions >>will include endpoint security, mobile security and the latest in malware >>threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >>>>________________________________ >> >>Cppcms-users mailing list >>Cpp...@li... >>https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. Discussions >will include endpoint security, mobile security and the latest in malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: Lee E. <lee...@gm...> - 2012-04-30 06:48:17
|
Here is my uneducated guess: you want to be able to get to the columnA (assuming it is a unique column) as both: "st.columnA" and "columnA" in order to do that you need to maintain the "st" table name for each colunm, and you need to parse the column name instead of just compare it. or alternatively you need to have several names for the same column. on the face of it it looks like the type of programming done in management environments and not in C++ - since just supporting those two names will mean slowing down access time to the columns. it gets worse - in order to keep that table name - the CppDB needs to actually parse the columns and table parts of the select statements instead of just passing it along to the db. again more work for a very limited gain. as a general rule - i try to avoid select * in my code. i prefer to list the columns one by one either in the SP or in the query and if you do that - you can give the columns unique names lee On Mon, Apr 30, 2012 at 3:20 AM, <ele...@ex...> wrote: > Hello, > > Supposing I have a SELECT * FROM sometable st LEFT OUTER JOIN othertable > ot ON (st.ot_id=ot.id) ... > > Then looping through the results using result::next() > > Why can't I access the results this way? > > r.get<string>("st.columnA") ? > > Imagine you want to get all the columns from both tables and some have > duplicate column names such as - id or name > > Petr > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- -- lee Lee Elenbaas lee...@gm... |
From: <ke...@co...> - 2012-04-30 06:42:17
|
At first. Never use select * http://stackoverflow.com/questions/1433971/select-from-table-or-select-id-field1-field2-field3-from-table-best-practi If you solve that problem then you can access them via integer index. The other one. Good question. Maybe artyom can say something about it. -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. ele...@ex... schrieb: Hello, Supposing I have a SELECT * FROM sometable st LEFT OUTER JOIN othertable ot ON (st.ot_id=ot.id) ... Then looping through the results using result::next() Why can't I access the results this way? r.get<string>("st.columnA") ? Imagine you want to get all the columns from both tables and some have duplicate column names such as - id or name Petr _____________________________________________ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _____________________________________________ Cppcms-users mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: <ele...@ex...> - 2012-04-30 00:20:42
|
Hello, Supposing I have a SELECT * FROM sometable st LEFT OUTER JOIN othertable ot ON (st.ot_id=ot.id) ... Then looping through the results using result::next() Why can't I access the results this way? r.get<string>("st.columnA") ? Imagine you want to get all the columns from both tables and some have duplicate column names such as - id or name Petr |
From: Artyom B. <art...@ya...> - 2012-04-27 06:16:00
|
----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > Cant you use request().getenv("HTTP_X_CSRFTOKEN"), in combination with > session_interface::validate_csrf_token() for checking presence? > validate_csrf_token uses getenv as one of the options. I don't see the point? How would it help. >> Also note, if the form update fails you should see a notice >> about it in logs. > > Do you mean the "CSRF Validation Failed" message? > The message is written as warning to logs: cppcms, warning: CSRF validation failed IP=XXX SCRIPT_NAME=/yyy PATH_INFO=/zzz (session_interface.cpp:120) Make sure that logging.level is set to at least warnings level, by default only errors are written. See: http://cppcms.com/wikipp/en/page/cppcms_1x_config#logging.level Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: <ele...@ex...> - 2012-04-26 22:37:15
|
Cant you use request().getenv("HTTP_X_CSRFTOKEN"), in combination with session_interface::validate_csrf_token() for checking presence? > Also note, if the form update fails you should see a notice > about it in logs. Do you mean the "CSRF Validation Failed" message? |
From: Artyom B. <art...@ya...> - 2012-04-26 14:59:34
|
Such feature would require parsing HTML and it may be not even possible when for example form is rendered from different locations. I thought about it, even thought how to automatize the process but it does not seems to be feasible. Also note, if the form update fails you should see a notice about it in logs. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ ----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > To: cpp...@li... > Cc: > Sent: Thursday, April 26, 2012 5:47 AM > Subject: [Cppcms-users] Suggestion: warn if csrf enabled but missing > > Hi, > > This is just a suggestion - > > I just spent about 20 minutes trying to figure out why I get forbidden > error(302) while trying to load context() into a rather complex form. And > I completely forgot about adding <% csrf %> to the form. > > It would be great if a warning was logged that csrf is enabled but token > is missing. > > Thanks, > Petr > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Artyom B. <art...@ya...> - 2012-04-26 14:56:12
|
The backtrace is improved in CppCMS trunk - switched to use libgcc's _Unwind_Backtrace that gives accurate results even when the software compiled with -fomit-frame-pointer. Updated stack tracing on FreeBSD and improved it on Solaris and Mac OS X. If it works good I'll add this to the stable release. Note, if somebody wants to try he is welcome to use trunk or take a chagneset 2171 Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: <ele...@ex...> - 2012-04-26 02:47:56
|
Hi, This is just a suggestion - I just spent about 20 minutes trying to figure out why I get forbidden error(302) while trying to load context() into a rather complex form. And I completely forgot about adding <% csrf %> to the form. It would be great if a warning was logged that csrf is enabled but token is missing. Thanks, Petr |
From: Lee E. <lee...@gm...> - 2012-04-25 21:17:13
|
I prefer a different approach: use cron or some other mechanism to trigger a request to maintanance URL to the application. and activation of wget or similar application with the proper URL can be done from cron - and will give the CppCMS all the necesary context request and response objects it needs. In addition it will make debugging and running maintanance jobs manually much easier On Wed, Apr 25, 2012 at 11:50 PM, Artyom Beilis <art...@ya...> wrote: > > > > >>> but if I try to access to the > >>> context .... > >>> > > >> > > >> See, cppcms::http::context is request/response context... Cron job > >> does not have any request/response as it is not initiated by > >> the client, so you are probably doing something wrong. > >> > > > > Maybe i have to be more specific. I don't want to access the context in > > general, i want access to the cache, to rise some triggers. > > > Ok... > > You had bring up very interesting point and actually the > problem in the CppCMS's API. > > You can't access cache interface without context, however > it should be possible to do some actions on the cache > itself as it is not 100% binded to request/response. > > This is some important point to implement and it requires > a feature request in the bug tracking system :-) > > As it seems to be a design flaw I'll try to take a look on it > ASAP. > > > As a workaround for you at this point: > ------------------------------------- > > > Have you tried to use cache timeouts instead of "cron job" > > Every object stored in cache may have expiration timeout, > it is the best way to invalidate cache by time. > > > > > > Just create a event using deadline_timer, > > > > but where to "start" this event? If I start it within the constructor of > > the async event, this would be wrong, wouldn't it? (this is how i get > > the px != 0 error) > > > > Take a look on general AIO examples. Best is something like create some > object > and then access to its memeber function that starts timers. > > class my_obj { > public: > my_obj(booster::aio::io_service &s) : timer_(s) {} > void async_run() > { > timer_.async_wait(...) > > } > void on_timeout(...) > { > > timer_.async_wait(...) > > } > > > private > > booster::aio::deadline_timer timer_; > > }; > > > ....... > > try { > cppcms::service srv(argc,argv); > > // this is your cron job > > my_obj obj(srv.get_io_service()); > obj.async_run(); > > srv.run(); > > } > > > > > > > >> and submit a job > >> to the thread pool or if it is something very short execute it in > >> the event loop itself. > > > >what is very short in your opinion? Any suggestions when to execute it > >in the thread pool and when not? > > Are you doing something blocking or do you do some heavy computations? > > Go to thread pool, otherwise do it in event loop. > > > Rising a trigger may be quite heavy if it invalidates many values. > > > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > -- -- lee Lee Elenbaas lee...@gm... |
From: Artyom B. <art...@ya...> - 2012-04-25 20:50:10
|
>>> but if I try to access to the >>> context .... >>> >> >> See, cppcms::http::context is request/response context... Cron job >> does not have any request/response as it is not initiated by >> the client, so you are probably doing something wrong. >> > > Maybe i have to be more specific. I don't want to access the context in > general, i want access to the cache, to rise some triggers. Ok... You had bring up very interesting point and actually the problem in the CppCMS's API. You can't access cache interface without context, however it should be possible to do some actions on the cache itself as it is not 100% binded to request/response. This is some important point to implement and it requires a feature request in the bug tracking system :-) As it seems to be a design flaw I'll try to take a look on it ASAP. As a workaround for you at this point: ------------------------------------- Have you tried to use cache timeouts instead of "cron job" Every object stored in cache may have expiration timeout, it is the best way to invalidate cache by time. > > Just create a event using deadline_timer, > > but where to "start" this event? If I start it within the constructor of > the async event, this would be wrong, wouldn't it? (this is how i get > the px != 0 error) > Take a look on general AIO examples. Best is something like create some object and then access to its memeber function that starts timers. class my_obj { public: my_obj(booster::aio::io_service &s) : timer_(s) {} void async_run() { timer_.async_wait(...) } void on_timeout(...) { timer_.async_wait(...) } private booster::aio::deadline_timer timer_; }; ....... try { cppcms::service srv(argc,argv); // this is your cron job my_obj obj(srv.get_io_service()); obj.async_run(); srv.run(); } >> and submit a job >> to the thread pool or if it is something very short execute it in >> the event loop itself. > >what is very short in your opinion? Any suggestions when to execute it >in the thread pool and when not? Are you doing something blocking or do you do some heavy computations? Go to thread pool, otherwise do it in event loop. Rising a trigger may be quite heavy if it invalidates many values. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: Marcel H. <ke...@co...> - 2012-04-25 12:32:59
|
Am 24.04.2012 22:16, schrieb Artyom Beilis: > >> but if I try to access to the >> context it says: "Assertion `px != 0' failed." > See, cppcms::http::context is request/response context... Cron job > does not have any request/response as it is not initiated by > the client, so you are probably doing something wrong. Maybe i have to be more specific. I don't want to access the context in general, i want access to the cache, to rise some triggers. > Just create a event using deadline_timer, but where to "start" this event? If I start it within the constructor of the async event, this would be wrong, wouldn't it? (this is how i get the px != 0 error) > and submit a job > to the thread pool or if it is something very short execute it in > the event loop itself. what is very short in your opinion? Any suggestions when to execute it in the thread pool and when not? > Artyom > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users |
From: Artyom B. <art...@ya...> - 2012-04-25 09:08:35
|
1. Register to mailing list so I would not have to moderate your questions 2. In terms of performance Wt is not even close to what CppCMS has to offer: * Wt does not even supports caching * Wt's session model is not scalable at all * All the "GUI-like" concept does not fit high performance models 3. The best to run CppCMS application behind a web server, so it is up to the web server to handle virtual hosts, also if you look at cppcms::mount_point documentation you'll see how to handle virtual hosts withing CppCMS itself. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Николай Шатохин <n.s...@gm...> >To: cpp...@li... >Sent: Tuesday, April 24, 2012 12:42 PM >Subject: [Cppcms-users] Virtual hosts > > >Hello. > > > >Does CppCMS support virtual hosts? Where can I find perfomance tests in comparison with Wt? > > >Best regards, >Nick. > >------------------------------------------------------------------------------ >Live Security Virtual Conference >Exclusive live event will cover all the ways today's security and >threat landscape has changed and how IT managers can respond. Discussions >will include endpoint security, mobile security and the latest in malware >threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: doug l. <bi...@gm...> - 2012-04-24 21:16:15
|
Ah, I have it -- it looks like there's some cppcms magic involved in constructing and handling forms. The fields "owner" and "data" in my form got translated in the markup into inputs with the non-natural names "_1" and "_2", like so: <form method="post" action=""> <p><span class="cppcms_form_input"><input type="file" name="_1" ></span></p> <p><span class="cppcms_form_input"><input type="text" name="_2" value="Ding" ></span></p> <p><span class="cppcms_form_input"><input type="submit" name="_3" value=" Upload" ></span></p> </form> And when I replicated this with cURL like so: $ curl localhost:8080/imageserver/abc -F _1="def" -F _2=@features/fixtures/img01.jpg It worked. So now I need to figure out how to submit a form to cppcms with fields named in a more natural manner, not "_1", "_2", etc. Which is progress! :) Cheers, Doug. |
From: Artyom B. <art...@ya...> - 2012-04-24 20:16:10
|
> Hi everyone, > > my web application uses some background processes for time based things, > e.g. "crons", but I need access to the content itself. What is the > best > way to do this? My first thought was to mount a backgroundprocess as > async process and make async_waits, Yes, this is correct approach, for example, sessions garbage collection works this way > but if I try to access to the > context it says: "Assertion `px != 0' failed." See, cppcms::http::context is request/response context... Cron job does not have any request/response as it is not initiated by the client, so you are probably doing something wrong. Just create a event using deadline_timer, and submit a job to the thread pool or if it is something very short execute it in the event loop itself. Artyom |