cppcms-users Mailing List for CppCMS C++ Web Framework (Page 80)
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: Artyom B. <art...@ya...> - 2012-07-02 08:57:12
|
Like any other process: Do stuff like this: int main(...) { try { cppcms::service srv(...) srv.run(); } catch(std::exception const &) { //Some problem return 1; } return 0; // exited normally } srv.run() returns upon srv.shutdown() (that is called by SIGTERM handler) Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Lee Elenbaas <lee...@gm...> >To: Artyom Beilis <art...@ya...>; cpp...@li... >Sent: Monday, July 2, 2012 10:53 AM >Subject: Re: [Cppcms-users] some graceful way to close the CppCMS app > > >Is there some way to return an error code to the program that run the cppcms app? >i would like to provide some conditioned loop in my batch/shell script > > >thanks > > >On Mon, Jul 2, 2012 at 10:34 AM, Artyom Beilis <art...@ya...> wrote: > >Two options: >> >> >>1. Send a SIGTERM signal to the application service it will shutdown gracefully. >>2. >From the application itself, use cppcms::service::shutdown() >> >> >>The open requests that started processing .i.e. it is processed in the thread_pool >>would be completed. The connections that had not got to thread pool (not started processing) >> >>and asynchronous connections will be closed. >> >>Artyom Beilis >>-------------- >>CppCMS - C++ Web Framework: http://cppcms.com/ >>CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >> >> >> >>>________________________________ >>> From: Lee Elenbaas <lee...@gm...> >>>To: cpp...@li... >>>Sent: Monday, July 2, 2012 10:17 AM >>>Subject: [Cppcms-users] some graceful way to close the CppCMS app >>> >>> >>> >>>Hi All, >>> >>> >>>Is there some gracefull way to close the CppCMS so that it will stop accepting new requests, finish handle the currently open requests and then close down with a given error code. >>>In my situation i sometimes need to close the app change the configuration and then run it again. And i am looking for a gracefull way to perform that. >>>(Yes i know that the embeded web server is not for production - but for my case i think it is the best option right now. I would have to bundle a webserver with my app anyway, so using this and configuring it to answer only localhost seems like a good enough option for now) >>> >>>-- >>>-- >>>lee >>>Lee Elenbaas >>>lee...@gm... >>> >>> >>>------------------------------------------------------------------------------ >>>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 >> >> > > > >-- >-- >lee >Lee Elenbaas >lee...@gm... > > >------------------------------------------------------------------------------ >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-07-02 07:53:37
|
Is there some way to return an error code to the program that run the cppcms app? i would like to provide some conditioned loop in my batch/shell script thanks On Mon, Jul 2, 2012 at 10:34 AM, Artyom Beilis <art...@ya...> wrote: > Two options: > > 1. Send a SIGTERM signal to the application service it will shutdown > gracefully. > 2. >From the application itself, use cppcms::service::shutdown() > > The open requests that started processing .i.e. it is processed in the > thread_pool > would be completed. The connections that had not got to thread pool (not > started processing) > and asynchronous connections will be closed. > > Artyom Beilis > -------------- > CppCMS - C++ Web Framework: http://cppcms.com/ > CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ > > ------------------------------ > *From:* Lee Elenbaas <lee...@gm...> > *To:* cpp...@li... > *Sent:* Monday, July 2, 2012 10:17 AM > *Subject:* [Cppcms-users] some graceful way to close the CppCMS app > > Hi All, > > Is there some gracefull way to close the CppCMS so that it will stop > accepting new requests, finish handle the currently open requests and then > close down with a given error code. > In my situation i sometimes need to close the app change the configuration > and then run it again. And i am looking for a gracefull way to perform > that. > (Yes i know that the embeded web server is not for production - but for my > case i think it is the best option right now. I would have to bundle a > webserver with my app anyway, so using this and configuring it to answer > only localhost seems like a good enough option for now) > > -- > -- > lee > Lee Elenbaas > lee...@gm... > > > > ------------------------------------------------------------------------------ > 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 > > -- -- lee Lee Elenbaas lee...@gm... |
From: Artyom B. <art...@ya...> - 2012-07-02 07:36:03
|
>Do you think it's worthwhile creating a wiki page to collate all utf8/encoding >FAQs? There was already a question on this list about cppdb and utf8. >I can create one if you wish. > >Augustin. > Not bad idea at all Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: Artyom B. <art...@ya...> - 2012-07-02 07:35:01
|
Two options: 1. Send a SIGTERM signal to the application service it will shutdown gracefully. 2. From the application itself, use cppcms::service::shutdown() The open requests that started processing .i.e. it is processed in the thread_pool would be completed. The connections that had not got to thread pool (not started processing) and asynchronous connections will be closed. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: Lee Elenbaas <lee...@gm...> >To: cpp...@li... >Sent: Monday, July 2, 2012 10:17 AM >Subject: [Cppcms-users] some graceful way to close the CppCMS app > > >Hi All, > > >Is there some gracefull way to close the CppCMS so that it will stop accepting new requests, finish handle the currently open requests and then close down with a given error code. >In my situation i sometimes need to close the app change the configuration and then run it again. And i am looking for a gracefull way to perform that. >(Yes i know that the embeded web server is not for production - but for my case i think it is the best option right now. I would have to bundle a webserver with my app anyway, so using this and configuring it to answer only localhost seems like a good enough option for now) > >-- >-- >lee >Lee Elenbaas >lee...@gm... > > >------------------------------------------------------------------------------ >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-07-02 07:18:16
|
Hi All, Is there some gracefull way to close the CppCMS so that it will stop accepting new requests, finish handle the currently open requests and then close down with a given error code. In my situation i sometimes need to close the app change the configuration and then run it again. And i am looking for a gracefull way to perform that. (Yes i know that the embeded web server is not for production - but for my case i think it is the best option right now. I would have to bundle a webserver with my app anyway, so using this and configuring it to answer only localhost seems like a good enough option for now) -- -- lee Lee Elenbaas lee...@gm... |
From: augustin <aug...@ov...> - 2012-07-02 06:51:13
|
On Monday, July 02, 2012 02:30:38 PM Artyom Beilis wrote: > The encoding option is not in use for a LOOOONG time :) Sorry! > > http://cppcms.com/wikipp/en/page/cppcms_1x_config#localization > > The correct solution is to define the locale for the cppcms service > > "localization" { > "locales" : [ "en_US.UTF-8" ] > } Thanks. I'll try that. Do you think it's worthwhile creating a wiki page to collate all utf8/encoding FAQs? There was already a question on this list about cppdb and utf8. I can create one if you wish. Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: Artyom B. <art...@ya...> - 2012-07-02 06:30:50
|
The encoding option is not in use for a LOOOONG time http://cppcms.com/wikipp/en/page/cppcms_1x_config#localization CppCMS automatically sets the Content-Type charset according to the process locale, if apache starts the web server using C locale than by default you'll get us-ascii charset. The correct solution is to define the locale for the cppcms service "localization" { "locales" : [ "en_US.UTF-8" ] } Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ >________________________________ > From: augustin <aug...@ov...> >To: cpp...@li... >Sent: Monday, July 2, 2012 9:15 AM >Subject: Re: [Cppcms-users] Apache utf8 headers > >On Monday, July 02, 2012 02:06:45 PM augustin wrote: >> Maybe I should use this: >> http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html >> but I am confused by the discrepancy between the two sites, given that >> they have the same code and the same settings. >> Can this be considered as a small bug in cppcms? > >I fixed this by adding the following in my application: > response().content_type("text/html; charset=UTF-8"); >but maybe this is not the most appropriate way to handle this, or cppcms could >have guessed the proper encoding from config.js. > >And if this is the proper solution, hopefully by putting it here, it will help >someone else. > > > >Augustin. > > > >-- >Friends: http://www.reuniting.info/ >My projects: >http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ >http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ >http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ >http://www.wechange.org/ http://searching911.info/ > > > > > > > > > > > > >. > >------------------------------------------------------------------------------ >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: augustin <aug...@ov...> - 2012-07-02 06:15:37
|
On Monday, July 02, 2012 02:06:45 PM augustin wrote: > Maybe I should use this: > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html > but I am confused by the discrepancy between the two sites, given that > they have the same code and the same settings. > Can this be considered as a small bug in cppcms? I fixed this by adding the following in my application: response().content_type("text/html; charset=UTF-8"); but maybe this is not the most appropriate way to handle this, or cppcms could have guessed the proper encoding from config.js. And if this is the proper solution, hopefully by putting it here, it will help someone else. Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: augustin <aug...@ov...> - 2012-07-02 06:07:07
|
Hello, I have 2 exactly identical web sites (same code, same html output), but one is set up to be started by the web server, and the other is set up to be started manually. See: http://cppcms.com/wikipp/en/page/cppcms_1x_tut_web_server_config#Apache In config.js, I have in both cases: "localization" : { "encoding" : "UTF-8", }, The html output contains in both cases: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> However, the apache headers are not the same. In the case of the manually started web site, the headers correctly specify: Content-Type text/html; charset=utf-8 while with the site started by the web server, the header specifies: Content-Type text/html; charset=us-ascii and thus I have to manually set my browser to display the web page in utf8 encoding to properly view the page. How come the apache Content-Type charset header is not the same? How to ensure the charset is the correct one? Also, where is the most appropriate place to rectify this? Should I set this in .htaccess? Should it be corrected from within the cppcms application, by declaring the proper http header? Should it be fixed in the apache settings for the web site (/etc/apache2/sites- available/mysite)? Maybe I should use this: http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1response.html but I am confused by the discrepancy between the two sites, given that they have the same code and the same settings. Can this be considered as a small bug in cppcms? Thanks, Augustin. -- Friends: http://www.reuniting.info/ My projects: http://astralcity.org/ http://lesenjeux.fr/ http://linux.overshoot.tv/ http://overshoot.tv/ http://charityware.info/ http://masquilier.org/ http://openteacher.info/ http://minguo.info/ http://jacqueslemaire.fr/ http://www.wechange.org/ http://searching911.info/ . |
From: <ele...@ex...> - 2012-06-26 11:37:43
|
Not to sound pushy, but if you are new to C++, i'd start with this: http://www.amazon.com/Accelerated-C-Practical-Programming-Example/dp/020170353X/ref=sr_1_1?ie=UTF8&qid=1340710529&sr=8-1&keywords=accelerated+c%2B%2B C++ is easy to give up on when you're starting and don't have the proper guidance. |
From: Marcel H. <ke...@co...> - 2012-06-26 09:50:13
|
Am 26.06.2012 02:23, schrieb Brian Lee: > Hey everyone, > > I just installed CppCMS on Windows with a MinGW shell. I'm still > pretty new to C++ and am setting up a web server as a learning > exercise, but I'm stuck at tutorial 3. I pretty much copy-pasted all > the code -- did I go wrong, or is there something wrong with my > environment? > > I'm getting compile errors using g++ (g++ hello.cpp -lcppcms -o hello): > > hello.cpp: In constructor, 'hello::hello(cppcms::service&)': > hello.cpp:14:43: error 'number' is not a member of 'hello' > hello.cpp:17:35: error: 'smile' is not a member of 'hello' > hello.cpp:20:29: error: 'welcome' is not a member of 'hello' everything you need is said here > hello.cpp: In function 'void number(std::string)': > hello.cpp:39:11: error: 'response' was not declared in this scope > hello.cpp:40:44: error: 'url' was not declared in this scope and again here > hello.cpp: In function 'void smile()': > hello.cpp:44:11: error: 'response' was not declared in this scope > hello.cpp:45:44: error: 'url' was not declared in this scope > hello.cpp:49:11: error: 'response' was not declared in this scope > hello.cpp:51:33: error: 'url' was not declared in this scope > and of course here ;) > > > #include <cppcms/application.h> > #include <cppcms/service.h> > #include <cppcms/http_response.h> > #include <cppcms/url_dispatcher.h> > #include <cppcms/url_mapper.h> > #include <cppcms/applications_pool.h> > #include <iostream> > #include <stdlib.h> > > class hello : public cppcms::application { > public: > hello(cppcms::service &srv) : > cppcms::application(srv) { > dispatcher().assign("/number/(\\d+)",&hello::number,this,1); > mapper().assign("number","/number/{1}"); > > dispatcher().assign("/smile",&hello::smile,this); you want a reference to the method smile in the class hello, but.... (see below) > mapper().assign("smile","/smile"); > > dispatcher().assign("",&hello::welcome,this); > mapper().assign(""); > > mapper().root("/hello"); > } > virtual void main(std::string url); > }; > > void hello::main(std::string url) { > response().out() << > "<html>\n" > "<body>\n" > " <h1>Hello, world!</h1>\n" > "</body>\n" > "</html>\n"; > } > > void number(std::string num) { > int no = atoi(num.c_str()); > response().out() << "The number is " << no << "<br/>\n"; > response().out() << "<a href='" << url("/") << "'>Go back</a>"; > } number is declared as function only, not as method from hello, for doing so, write void hello:number(std::string num), but better would be void hello:number(const std::string &num) > > void smile() { > response().out() << ":) <br/>\n"; > response().out() << "<a href='" << url("/") << "'>Go back</a>"; > } smile as number > > void welcome() { > response().out() << > "<h1> Wellcome To Page with links </h1>\n" > "<a href='" << url("/number",1) << "'>1</a><br>\n" > "<a href='" << url("/number",15) << "'>15</a><br>\n" > "<a href='" << url("/smile") << "' >:)</a><br>\n"; > } the same here > > int main(int argc, char ** argv) { > try { > cppcms::service srv(argc, argv); > srv.applications_pool().mount ( > cppcms::applications_factory<hello>() > ); > srv.run(); > } > catch(std::exception const&e) { > std::cerr << e.what() << std::endl; > } > } > > Any help would be much appreciated. > I hope this helps ;) > Regards, > Brian Marcel > > > ------------------------------------------------------------------------------ > 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: kpeo <sla...@ya...> - 2012-06-26 06:55:56
|
Hello, You use functions as &hello::number in dispatcher, but not declare it inside class. So declare it below "main": class hello ... { ... virtual void main(std::string url); void number(std::string); void smile(); void welcome(); }; and write it below as "hello::number", etc. instead "number": void hello::number(std::string num) { int no = atoi(num.c_str()); response().out() << "The number is " << no << "<br/>\n"; response().out() << "<a href='" << url("/") << "'>Go back</a>"; } > Hey everyone, > > I just installed CppCMS on Windows with a MinGW shell. I'm still pretty new to C++ and am setting up a web server as a learning exercise, but I'm stuck at tutorial 3. I pretty much copy-pasted all the code -- did I go wrong, or is there something wrong with my environment? > > I'm getting compile errors using g++ (g++ hello.cpp -lcppcms -o hello): ... > class hello : public cppcms::application { > public: > hello(cppcms::service &srv) : > cppcms::application(srv) { > dispatcher().assign("/number/(\\d+)",&hello::number,this,1); > > mapper().assign("number","/number/{1}"); > > dispatcher().assign("/smile",&hello::smile,this); > mapper().assign("smile","/smile"); > > dispatcher().assign("",&hello::welcome,this); > mapper().assign(""); > > mapper().root("/hello"); > } > virtual void main(std::string url); > > }; > > void hello::main(std::string url) { > response().out() << > "<html>\n" > "<body>\n" > " <h1>Hello, world!</h1>\n" > > "</body>\n" > "</html>\n"; > } > > void number(std::string num) { > int no = atoi(num.c_str()); > response().out() << "The number is " << no << "<br/>\n"; > > response().out() << "<a href='" << url("/") << "'>Go back</a>"; > } > > void smile() { > response().out() << ":) <br/>\n"; > > response().out() << "<a href='" << url("/") << "'>Go back</a>"; > } > > void welcome() { > response().out() << > "<h1> Wellcome To Page with links </h1>\n" > > "<a href='" << url("/number",1) << "'>1</a><br>\n" > "<a href='" << url("/number",15) << "'>15</a><br>\n" > > "<a href='" << url("/smile") << "' >:)</a><br>\n"; > } > > int main(int argc, char ** argv) { > try { > cppcms::service srv(argc, argv); > > srv.applications_pool().mount ( > cppcms::applications_factory<hello>() > ); > srv.run(); > } > catch(std::exception const&e) { > std::cerr << e.what() << std::endl; > > } > } > > Any help would be much appreciated. > > Regards, > Brian |
From: Brian L. <to...@gm...> - 2012-06-26 00:23:49
|
Hey everyone, I just installed CppCMS on Windows with a MinGW shell. I'm still pretty new to C++ and am setting up a web server as a learning exercise, but I'm stuck at tutorial 3. I pretty much copy-pasted all the code -- did I go wrong, or is there something wrong with my environment? I'm getting compile errors using g++ (g++ hello.cpp -lcppcms -o hello): hello.cpp: In constructor, 'hello::hello(cppcms::service&)': hello.cpp:14:43: error 'number' is not a member of 'hello' hello.cpp:17:35: error: 'smile' is not a member of 'hello' hello.cpp:20:29: error: 'welcome' is not a member of 'hello' hello.cpp: In function 'void number(std::string)': hello.cpp:39:11: error: 'response' was not declared in this scope hello.cpp:40:44: error: 'url' was not declared in this scope hello.cpp: In function 'void smile()': hello.cpp:44:11: error: 'response' was not declared in this scope hello.cpp:45:44: error: 'url' was not declared in this scope hello.cpp:49:11: error: 'response' was not declared in this scope hello.cpp:51:33: error: 'url' was not declared in this scope #include <cppcms/application.h> #include <cppcms/service.h> #include <cppcms/http_response.h> #include <cppcms/url_dispatcher.h> #include <cppcms/url_mapper.h> #include <cppcms/applications_pool.h> #include <iostream> #include <stdlib.h> class hello : public cppcms::application { public: hello(cppcms::service &srv) : cppcms::application(srv) { dispatcher().assign("/number/(\\d+)",&hello::number,this,1); mapper().assign("number","/number/{1}"); dispatcher().assign("/smile",&hello::smile,this); mapper().assign("smile","/smile"); dispatcher().assign("",&hello::welcome,this); mapper().assign(""); mapper().root("/hello"); } virtual void main(std::string url); }; void hello::main(std::string url) { response().out() << "<html>\n" "<body>\n" " <h1>Hello, world!</h1>\n" "</body>\n" "</html>\n"; } void number(std::string num) { int no = atoi(num.c_str()); response().out() << "The number is " << no << "<br/>\n"; response().out() << "<a href='" << url("/") << "'>Go back</a>"; } void smile() { response().out() << ":) <br/>\n"; response().out() << "<a href='" << url("/") << "'>Go back</a>"; } void welcome() { response().out() << "<h1> Wellcome To Page with links </h1>\n" "<a href='" << url("/number",1) << "'>1</a><br>\n" "<a href='" << url("/number",15) << "'>15</a><br>\n" "<a href='" << url("/smile") << "' >:)</a><br>\n"; } int main(int argc, char ** argv) { try { cppcms::service srv(argc, argv); srv.applications_pool().mount ( cppcms::applications_factory<hello>() ); srv.run(); } catch(std::exception const&e) { std::cerr << e.what() << std::endl; } } Any help would be much appreciated. Regards, Brian |
From: <ele...@ex...> - 2012-06-24 11:02:47
|
Good idea. Although I'd call the guard class "transaction_guard" instead to let the user know that cppdb::transaction and cppdb::transaction_guard guard are related. Either that or nest the guard class inside transaction. Which one do you prefer? |
From: Artyom B. <art...@ya...> - 2012-06-24 10:21:45
|
I think it would be better to create some kind of generic guard class with different commits/rollbacks: // information about statements class guard { guard(); guard(std::string const &on_start) guard(std::string const &on_start, std::string const &on_commit); guard(std::string const &on_start, std::string const &on_commit, std::string const &on_rollback); // set explicitly void on_start(std::string const &); // default begin void on_commit(std::string const &); // default commit void on_rollback(std::string const &); // default rollback; }; Now out transaction constructors would look like: // ordinary transaction transaction(cppdb::session &sql); // custom transaction transaction(cppdb::session &sql,guard const &g); Now when I can run stuff like cppdb::guard myguard("BEGIN IMMEDIATE"); cppdb::scope tr(sql,myguard); ... tr.commit(); or use it with savepoints or nested transactions Define guard cppdb::guard myguard( "SAVEPOINT temp", "ROLLBACK TO SAVEPOINT temp", "RELEASE SAVEPOINT temp"); or more explicitlu cppdb::guard myguard; myguard.on_start("SAVEPOINT temp"); myguard.on_commit("RELEASE SAVEPOINT temp"); myguard.on_rollback("ROLLBACK TO SAVEPOINT temp"); And now do stuff like: cppdb::transaction tr(sql); for(...) { cppdb::transaction sp(sql,myguard); ... sp.commit(); } tr.commit(); This would be much more complete interface. 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...> > > Here is another idea. > > 1) Create a cppdb::base_transaction class and implement the current > cppdb::transaction in it, but without calling begin() in it's constructor. > > Make its functions/destructor virtual if users want to overload & support > polymorphism. > > 2) Make cppdb::transaction inherit from base_transaction and call > session::begin() in it's constructor, so that current behavior is kept and > there wont be any API breakage. > > 3) Users will then be able to inherit from cppdb::base_transaction and > create their own transaction classes. > > This should avoid adding a default constructor and possibly confuse users. > > Is this a solid proposal 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: <ele...@ex...> - 2012-06-24 06:17:28
|
Here is another idea. 1) Create a cppdb::base_transaction class and implement the current cppdb::transaction in it, but without calling begin() in it's constructor. Make its functions/destructor virtual if users want to overload & support polymorphism. 2) Make cppdb::transaction inherit from base_transaction and call session::begin() in it's constructor, so that current behavior is kept and there wont be any API breakage. 3) Users will then be able to inherit from cppdb::base_transaction and create their own transaction classes. This should avoid adding a default constructor and possibly confuse users. Is this a solid proposal Artyom? |
From: <ele...@ex...> - 2012-06-24 05:57:19
|
I didn't want to re-open the bug again, but there's a still an idea i'd like to discuss. Artyom mentioned creating a "custom" transaction class to support something like BEGIN {EXCLUSIVE|IMMEDIATE} An idea would be to add a default constructor to cppcdb::transaction so that users can inherit from it instead of creating standalone transaction classes. The current constructor cppdb::transaction(cppdb::session&) calls begin() within itself so it cannot be modified. Maybe we could also add a cppdb::transaction_base interface class with virtual commit() = 0 and rollback() = 0 functions. If Artyom thinks this might be useful, I can create a patch to support such functionality. Petr |
From: Artyom B. <art...@ya...> - 2012-06-23 16:38:44
|
>> GCC 4.6.3 has it (4.7.x respectively as well) >> http://gcc.gnu.org/onlinedocs/gcc-4.6.3/libstdc++/api/a01192.html >> >> Did not lookup if earlier versions of gcc have the regex support as well. >> > >Ok... gcc-4.5 had not supported it (it was the last time I checked) >also it seems that gcc-4.6 does supports it. Older version allowed me to compile >the code but the "match result" was always false. > After a little check gcc-4.7 does not support regular expressions yet... a simple regex r("foo"); char const *b="xfooz"; char const *e=b+strlen(b); std::cout << regex_search(b,e,r) << std::endl; Prints 0 (of course with boost::regex it prints expected result 1) So it is too early to remove PCRE Artyom |
From: Artyom B. <art...@ya...> - 2012-06-23 09:46:36
|
Hello, CppDB 0.3.1 Released It is a bugfix release and it includes several critical bug fixes. It is strongly recommended to upgrade to the latest version! Changelog: http://cppcms.com/sql/cppdb/changelog.html Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: <ele...@ex...> - 2012-06-21 11:38:44
|
> In C and C++ you read definitions from right to left and from inside out > > int const *p[10] Are you sure? in C ok, but in C++ any STL code ive ever seen reads "const class& o". Even Bjarne writes it that way. It's simply more understandable, at least to me. Im not arguing with you, its the way you like it, that's the way you'll get it. But I find it hardly "more understanding" If anything "const char* const p" is a lot more logical as saying "p is const and it's type is const char pointer" To each of their own I guess, i just personally can't stand a lonely * or &, it looks messy imo :) Petr |
From: Artyom B. <art...@ya...> - 2012-06-21 11:06:33
|
----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > To: Artyom Beilis <art...@ya...>; cpp...@li... > Cc: > Sent: Thursday, June 21, 2012 1:54 PM > Subject: Re: [Cppcms-users] How to set default response().out() stream precision? > >> void on_before_stream_output(booster::function<(cppcms::http::context >> &)> const &); >> void on_after_stream_output(booster::function<(cppcms::http::context > &)> >> const &); >> >> Such a patch I can accept as it makes much more sense and may be actually >> useful >> for other things as well like altering a session or HTTP headers globally. > > I like this solution. > > I'll set the precision in the "master" view for now and then in > the next > few days when I(hopefully) get some spare time I'll look into it. > Ok > One more thing... are you keen on using the same const order? > > I've always been doing "const cppcms::http::context&" instead > of > "cppcms::http::context const &" > > Petr > Small note the const refers to booster::function not to http::context And yes because it is more consitent In C and C++ you read definitions from right to left and from inside out int const *p[10] array of size 10 of pointers to constant int. Now lets see three different definitions 1. const int **p; 2. int const **p; 3. int * const *p; 4. int ** const p 5. int const * const * const p; 6. const int * const * const p; Note that 1==2 and 5==6 But when you read for example 2, 3 and 4 4 - constant pointer to pointer to (mutable) int 3 - pointer to constant pointer to (mutable) int 2 - pointer to pointer to constant it. This makes the position of const much more consistent and easy to read especially for stuff like const int * const &p; Is harder to understand visually then int const * const &p; 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 > |
From: 陈抒 <csf...@gm...> - 2012-06-21 11:01:04
|
Hello Artyom: I left Lifeix serveral months ago, as far as I know, they are still using lottery system developed by my team based on CppCMS, but no new products using CppCMS now. You maybe change the description like so: Lifeix (立方网) <http://www.l99.com/> - XBox - a lottery system(a restful web service based on CppCMS and CppDB) I developed another web site using your CppCMS for my friend. It also uses your log library. Have a look at it from the URL below: www.cmltechnology.com. Change Language menu from 中文 to English, you will see the English description. Your library saved me a lot of time and money, also taught me a lot. Thanks. 陈抒 Best regards http://blog.csdn.net/sheismylife On Thu, Jun 21, 2012 at 6:06 PM, Artyom Beilis <art...@ya...> wrote: > > > ----- Original Message ----- > > From: "ele...@ex..." <ele...@ex...> > > To: Artyom Beilis <art...@ya...>; > cpp...@li... > > Cc: > > Sent: Thursday, June 21, 2012 12:54 PM > > Subject: Re: [Cppcms-users] Who Uses CppCMS - Reminder > > > > I'll let you know when my client accepts it :) > > > > Which will hopefully be soon... > > > > Looking forward > > > It will be a good ad for you, trust me. > > > > hint: "CPPCMS is so good we trust it in aviation" :) > > > > Petr > > > > > Nice... Indeed it would very good "quality measure". > > (I have some background in aviation) > > > 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 > |
From: <ele...@ex...> - 2012-06-21 10:54:13
|
> void on_before_stream_output(booster::function<(cppcms::http::context > &)> const &); > void on_after_stream_output(booster::function<(cppcms::http::context &)> > const &); > > Such a patch I can accept as it makes much more sense and may be actually > useful > for other things as well like altering a session or HTTP headers globally. I like this solution. I'll set the precision in the "master" view for now and then in the next few days when I(hopefully) get some spare time I'll look into it. One more thing... are you keen on using the same const order? I've always been doing "const cppcms::http::context&" instead of "cppcms::http::context const &" Petr |
From: Artyom B. <art...@ya...> - 2012-06-21 10:34:54
|
----- Original Message ----- > From: "ele...@ex..." <ele...@ex...> > To: Artyom Beilis <art...@ya...>; cpp...@li... > Cc: > Sent: Thursday, June 21, 2012 1:17 PM > Subject: Re: [Cppcms-users] How to set default response().out() stream precision? > >> <% gt "{1,precision =10}" using my_high_precision_value > %> > > That's just not feasible. If I had to do it for every number on the page, > id have to spend like a whole day changing it all. > >> If you need to change it globally create a small function in you topmost >> application >> class that all your classes are derived from: >> >> void render(std::string const &template_name,cppcms::basi_context > &c) >> { >> response().out() << std::setprecision(10); >> cppcms::application::render(template_name,c); >> } > > > Yes yes, I'm aware of this. However because the render functions are not > virtual, so they are not intended for overloading. At least that's the way > i've been taught so I did not want to do this either. > See, you can override non-virtual function as well but the parent classes you call the old one. In our case it is not used by parent (application) class, it rather provides convenience interface to base_content::app_guard g(content,my_app); service().views_pool().render(my_app.context().skin(),template_name,my_app.response().out(),content); So this is not a problem - may be not the most beautiful solution but it works and consistent with the standard. If you don't like this create some other "hp_render" function and refactor the code in much fewer places. > Anyway, is there are a reason they are not virtual? There's other > functions cppcms::application that are virtual. > > Petr > Generally the only functions that are virtual are thous that are expected to be overridden. I can suggest an another option, consider you have some global skin: <% template master uses master %> <html> <head> .... <% end template %> Just add a simple code like: <% template master uses master %> <% c++ out()<<std::setprecision(10) %> <html> <head> .... <% end template %> And every template that derives from the master page would include it... See, there are many things you can do to override the default of the standard C++ std::ostream. It is not a big problem. Also if you are looking for correct solution for global altering of response().out() settings at cppcms level you may want to add some callbacks to cppcms::http::response like void on_before_stream_output(booster::function<(cppcms::http::context &)> const &); void on_after_stream_output(booster::function<(cppcms::http::context &)> const &); Such a patch I can accept as it makes much more sense and may be actually useful for other things as well like altering a session or HTTP headers globally. Artyom Beilis -------------- CppCMS - C++ Web Framework: http://cppcms.com/ CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/ |
From: <ele...@ex...> - 2012-06-21 10:17:43
|
> <% gt "{1,precision =10}" using my_high_precision_value %> That's just not feasible. If I had to do it for every number on the page, id have to spend like a whole day changing it all. > If you need to change it globally create a small function in you topmost > application > class that all your classes are derived from: > > void render(std::string const &template_name,cppcms::basi_context &c) > { > response().out() << std::setprecision(10); > cppcms::application::render(template_name,c); > } Yes yes, I'm aware of this. However because the render functions are not virtual, so they are not intended for overloading. At least that's the way i've been taught so I did not want to do this either. Anyway, is there are a reason they are not virtual? There's other functions cppcms::application that are virtual. Petr |