Thread: [Cppcms-users] Migration Guide
Brought to you by:
artyom-beilis
From: Markus R. <mai...@ma...> - 2012-03-03 14:09:49
|
Hi! I started a migration guide from 0.x to 1.x. It is basically a step by step what I needed to do to port my 0.x application: http://cppcms.com/wikipp/en/page/cppcms_1x_migration The guide (and the porting) is not yet finished, I have some preliminary questions: For settings() it seems like that a const is missing. I could not find a page about the accessing of the configuration in the wiki, so maybe I am missing something. Btw. it would be nice to have a full text search somewhere in the wiki, because the navigation is far from perfect - there are not many links interconnecting the pages. Is it a bug that on some browsers (firefox, chrome) the source code of wikipp has two spaces at the end of the line when being copied? In konqueror no spaces are appended. What is the replacement from the previous env->getQueryString(); and cgicc::CgiEnvironment? Maybe some tutorial page how to access this information directly would be nice. best regards Markus |
From: Artyom B. <art...@ya...> - 2012-03-03 20:25:56
|
> From: Markus Raab <mai...@ma...> > To: cpp...@li... > Cc: First of all please register this e-mail to the mailing list so I would not have to moderate it. > Hi! > > I started a migration guide from 0.x to 1.x. It is basically a step by step > what I needed to do to port my 0.x application: > http://cppcms.com/wikipp/en/page/cppcms_1x_migration > First of all I'm quite surprised that there are still 0.0.8 users around. Almost all CppCMS users actually develop using CppCMS 1.x.x version even during its beta. > The guide (and the porting) is not yet finished, I have some preliminary > questions: > > For settings() it seems like that a const is missing. I could not find a page > about the accessing of the configuration in the wiki, so maybe I am missing > something. > Settings returns cppcms::json::value object. Read: http://cppcms.com/wikipp/en/page/cppcms_1x_json http://cppcms.com/cppcms_ref/latest/namespacecppcms_1_1json.html http://cppcms.com/cppcms_ref/latest/classcppcms_1_1json_1_1value.html > Btw. it would be nice to have a full text search somewhere in the wiki, > because the navigation is far from perfect - there are not many links > interconnecting the pages. > I know... It is the question of time (which I don't have too much) and priorities Meanwhile google has very good index for the web site, including reference documentation. > Is it a bug that on some browsers (firefox, chrome) the source code of wikipp > has two spaces at the end of the line when being copied? In konqueror no > spaces are appended. I don't understand the question, you mean extra spaces when you press on "view plain" ? > > What is the replacement from the previous env->getQueryString(); and > cgicc::CgiEnvironment? Maybe some tutorial page how to access this > information directly would be nice. > You should use cppcms::http::request. http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html Fir example env->getQueryString() goes to request().query_string() CppCMS 1.0.0 does not use CgiCC any more (CgiCC allows to start CppCMS easily but it wasn't really good library in long term). > best regards > Markus > Best, Artyom |
From: Artyom B. <art...@ya...> - 2012-03-03 20:36:42
|
> > For settings() it seems like that a const is missing. In general there are few const methods in CppCMS. mostly because it allow to have some side effects that for example allow caching or lazy initialization. So I'd generally recommend to use non-const member function withing cppcms application derived classes. Artyom |
From: Markus R. <us...@ma...> - 2012-03-04 15:02:44
|
Hi! First of all, congratulation for cppcms 1.0. It is a really great piece of software! Artyom Beilis wrote: >> For settings() it seems like that a const is missing. > > In general there are few const methods in CppCMS. > > mostly because it allow to have some side effects > that for example allow caching or lazy initialization. Ok, I understand. I am rather a fan of Scott Meyers: Use const whenever possible. For caching and logging I typically use mutable, because from logical point of view they still give the user constness. I have to admit, however, that I never build such an advanced caching system like cppcms has, it could be easily possible that you will get crazy when you try to have more const methods ;) > So I'd generally recommend to use non-const member function withing > cppcms application derived classes. Ok, so I will do that! best regards Markus -- http://www.markus-raab.org | Begeisterung ist alles! -- A.v. Wilbrandt, -o) | Fridolins heimliche Ehe Kernel 2.6.32-5-a /\ | on a x86_64 _\_v | |
From: Artyom B. <art...@ya...> - 2012-03-04 15:18:34
|
> From: Markus Raab <us...@ma...> > > First of all, congratulation for cppcms 1.0. > It is a really great piece of software! Thanks... :-) > > Ok, I understand. I am rather a fan of Scott Meyers: Use const whenever > possible. > The biggest problem is that const does not really works well with pimpl-design. Because with pipml almost everything can be const however semantically it may be non-const: For example the following construction is 100% correct from C++ point of view (d is not changed) but semantically it is by no means const. class foo { public: ... void bar() const { d->x++; } ... private: ... struct impl { int x; }; impl *d; }; So you can easily make wrong assumptions based on const or non-const interface. Const works very well for real data structures but it is not the best for complex systems with complex relations. For example classes like `cppcms::json::value` or `cppcms::http::cookie` have dual const/non-const interface because they are data structures. But many classes do not have such clear and easy separation. Best, Artyom |
From: Markus R. <us...@ma...> - 2012-03-04 18:04:11
|
Hi! Artyom Beilis wrote: >> From: Markus Raab <mai...@ma...> > >> To: cpp...@li... >> Cc: > > First of all please register this e-mail to the mailing > list so I would not have to moderate it. Sorry, the post was from a wrong e-mail address. >> I started a migration guide from 0.x to 1.x. It is basically a step by >> step what I needed to do to port my 0.x application: >> http://cppcms.com/wikipp/en/page/cppcms_1x_migration >> > > First of all I'm quite surprised that there are still 0.0.8 users > around. Almost all CppCMS users actually develop using CppCMS 1.x.x > version even during its beta. Yeah, I was also using CppCMS 1.x.x for some time now. But I had some legacy code which needed to be ported to 1.x. I am sure, however, I am not the only one in this situation, so I finished the article: http://cppcms.com/wikipp/en/page/cppcms_1x_migration CppCMS 1.x is vastly superior to 0.x - I realized that again during porting ;) >> The guide (and the porting) is not yet finished, I have some preliminary >> questions: >> >> For settings() it seems like that a const is missing. I could not find a >> page about the accessing of the configuration in the wiki, so maybe I am >> missing something. >> > > Settings returns cppcms::json::value object. > > Read: > > http://cppcms.com/wikipp/en/page/cppcms_1x_json > http://cppcms.com/cppcms_ref/latest/namespacecppcms_1_1json.html > > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1json_1_1value.html I am not very fond of json as configuration format - even though it is very good as data exchange format - because it lacks comments. What do you think about a patch which let you switch to http://www.libelektra.org/ at compiletime if preferred? Basically it would be just an alternative implementation of json::value service::load_settings(int argc,char *argv[]) What do you think? >> Btw. it would be nice to have a full text search somewhere in the wiki, >> because the navigation is far from perfect - there are not many links >> interconnecting the pages. >> > > I know... It is the question of time (which I don't have too much) > and priorities > > Meanwhile google has very good index for the web site, including reference > documentation. Ok. >> Is it a bug that on some browsers (firefox, chrome) the source code of >> wikipp has two spaces at the end of the line when being copied? In >> konqueror no spaces are appended. > > I don't understand the question, you mean extra spaces when you press on > "view plain" ? Steps to reproduce: Go to http://cppcms.com/wikipp/en/page/cppcms_1x_json with firefox/chrome Select some text of a sourcecode, press ctrl+c and ctrl+v or middle mouse. I get: my_object["name"]="Moshe"; my_object["salary"]=1000.0; (Note the two spaces at the end of each line) I expect: No spaces at the end of lines. It seems to be some problem within the syntax highlighter, which generates a "<span>; </span>" that adds these two spaces. It is a little bit strange, because the line numbers are suppressed successfully. Workaround: Press "view plain" and copy there. >> What is the replacement from the previous env->getQueryString(); and >> cgicc::CgiEnvironment? Maybe some tutorial page how to access this >> information directly would be nice. >> > > You should use cppcms::http::request. > > http://cppcms.com/cppcms_ref/latest/classcppcms_1_1http_1_1request.html > > > Fir example env->getQueryString() goes to request().query_string() > > CppCMS 1.0.0 does not use CgiCC any more (CgiCC allows to start CppCMS > easily but it wasn't really good library in long term). Yeah, the decision to drop CgiCC is ok, cppcms is now more homogen and easier to use. best regards Markus Raab |
From: Artyom B. <art...@ya...> - 2012-03-04 21:09:58
|
> Yeah, I was also using CppCMS 1.x.x for some time now. > But I had some legacy code which needed to be ported to 1.x. > I am sure, however, I am not the only one in this situation, so I finished > the article: > http://cppcms.com/wikipp/en/page/cppcms_1x_migration > > CppCMS 1.x is vastly superior to 0.x - I realized that again during > porting ;) > Yes, I've began to write it but then left as I thought it was not really required as most of the users had already switched by now. > > I am not very fond of json as configuration format - even though it is very > good as data exchange format - because it lacks comments. Actually I was sure that it was mentioned in documentation (but I can't find it now) CppCMS json parser supports two extensions to the standard json syntax, that make it very easy to use for configuration: 1. C++ style comments i.e. "//" 2. It ignores trailing comma in objects and array definitions so stuff like that works. { "foo" : 10, "bar" : 20, // "baz" : 30 } It makes it very suitable as configuration file format. > What do you think > about a patch which let you switch to http://www.libelektra.org/ at > compiletime if preferred? > > Basically it would be just an alternative implementation of > json::value service::load_settings(int argc,char *argv[]) > > What do you think? > I'm not really fond of adding more 3rd party dependencies. What is the license libelektra distributed under? > >> I don't understand the question, you mean extra spaces when you press > on >> "view plain" ? > > Steps to reproduce: > Go to http://cppcms.com/wikipp/en/page/cppcms_1x_json with firefox/chrome > Select some text of a sourcecode, press ctrl+c and ctrl+v or middle mouse. > > I get: > my_object["name"]="Moshe"; > my_object["salary"]=1000.0; > (Note the two spaces at the end of each line) > > I expect: > No spaces at the end of lines. > > It seems to be some problem within the syntax highlighter, which generates > a "<span>; </span>" that adds these two spaces. It is a > little bit strange, > because the line numbers are suppressed successfully. > > Workaround: > Press "view plain" and copy there. > I assume that this is syntax highlighter bug (I hadn't written it, I just use it) > > Yeah, the decision to drop CgiCC is ok, cppcms is now more homogen and > easier to use. > Also CgiCC was quite buggy and limited :-) I don't miss it. > best regards > Markus Raab > Regards, Artyom |
From: Markus R. <us...@ma...> - 2012-03-05 14:52:55
|
Hi! Artyom Beilis wrote: >> Yeah, I was also using CppCMS 1.x.x for some time now. > >> But I had some legacy code which needed to be ported to 1.x. >> I am sure, however, I am not the only one in this situation, so I >> finished the article: >> http://cppcms.com/wikipp/en/page/cppcms_1x_migration >> >> CppCMS 1.x is vastly superior to 0.x - I realized that again during >> porting ;) >> > > Yes, I've began to write it but then left as I thought it was not > really required as most of the users had already switched by now. Yeah, you are right. But there is always some legacy code somewhere. >> I am not very fond of json as configuration format - even though it is >> very good as data exchange format - because it lacks comments. > > Actually I was sure that it was mentioned in documentation (but I can't > find it now) There are many discussions about the lacking of comments. > CppCMS json parser supports two extensions to the standard json syntax, > that make it very easy to use for configuration: > > 1. C++ style comments i.e. "//" > 2. It ignores trailing comma in objects and array definitions > so stuff like that works. > > { > "foo" : 10, > "bar" : 20, > // "baz" : 30 > } Yeah, that are useful extensions but in the end it is not json anymore. Perl implemented # comments and others may do other or do not support them at all. > It makes it very suitable as configuration file format. > >> What do you think >> about a patch which let you switch to http://www.libelektra.org/ at >> compiletime if preferred? >> >> Basically it would be just an alternative implementation of >> json::value service::load_settings(int argc,char *argv[]) >> >> What do you think? >> > > I'm not really fond of adding more 3rd party dependencies. > > What is the license libelektra distributed under? It is BSD licenced. And as described: you can choose at build time if you want that dependency or not. >>> I don't understand the question, you mean extra spaces when you press >> on >>> "view plain" ? >> >> Steps to reproduce: >> Go to http://cppcms.com/wikipp/en/page/cppcms_1x_json with firefox/chrome >> Select some text of a sourcecode, press ctrl+c and ctrl+v or middle >> mouse. >> >> I get: >> my_object["name"]="Moshe"; >> my_object["salary"]=1000.0; >> (Note the two spaces at the end of each line) >> >> I expect: >> No spaces at the end of lines. >> >> It seems to be some problem within the syntax highlighter, which >> generates a "<span>; </span>" that adds these two spaces. It is a >> little bit strange, >> because the line numbers are suppressed successfully. >> >> Workaround: >> Press "view plain" and copy there. >> > > I assume that this is syntax highlighter bug > > (I hadn't written it, I just use it) Yeah, I think that too. So its up to me to report the bug there I assume ;) >> Yeah, the decision to drop CgiCC is ok, cppcms is now more homogen and >> easier to use. >> > > Also CgiCC was quite buggy and limited :-) > I don't miss it. ;) best regards Markus |
From: Artyom B. <art...@ya...> - 2012-03-05 16:04:05
|
>> CppCMS json parser supports two extensions to the standard json syntax, >> that make it very easy to use for configuration: > > Yeah, that are useful extensions but in the end it is not json anymore. > Perl implemented # comments and others may do other or do not support them > at all. I mean in context of the configuration file context not in general >>> What do you think >>> about a patch which let you switch to http://www.libelektra.org/ at >>> compiletime if preferred? >>> >> >> What is the license libelektra distributed under? > > It is BSD licenced. And as described: you can choose at build time if you > want that dependency or not. > From what I can seen from the quick glance that libelektra does not support arrays. Many data structures in the CppCMS configuration files are arrays and they are not 1-to-1 convertible to "registry" style operations. In any case, CppCMS's settings is based on JSON, if you want to use other formats it should be possible to convert them to JSON object and then you can start CppCMS main service as cppcms::json::value settings; settings = // load from whatever you want from cppcms::service srv(settings); Including converting from example from "Elektra" format to JSON one. If you want to create a patch that allows converting elektra to cppcms::json::value then I can put it under "contrib" section. Please note this Copyrights section http://cppcms.com/wikipp/en/page/cppcms_1x_coding_standards#Copyrights For submitting patches. Best Regards, Artyom |