Re: [Cppcms-users] Plugins, Localization, script_names, url mapper
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-03-02 18:12:39
|
> > In the first example of the plugin interface you pass > the application pointer to the plugin. I think it > would be more decoupled if the plugin could create > its own stripped down application just for rendering. It is up to you, really. I just had shown the general concept how it can be done. > Btw. the functions rendering to a stream should be > const, or do they modify the application? That change > would however break the API.. > It is not const. Because when you call render to access response().out() that does many things under the hood. So even thou technically it may be const. Semantically it does not have to. > Is there any approach how to get booster::locale working > Inside own plugins? > No problem: 1. All applications that are build in hierarchy share same http::context() that holds the locale, 2. Also the response().out() stream has std::locale imbued inside it. That is why you can call for example <% gt ... %> from the view. Of course if you render to your own std::ostream then you should imbue the std::locale object. my_stream.imbue(context().locale()); But it is better to use <% render ... %> template to render the plugin's view, this way you don\t use intermediate buffers and render to the same ostream. > Is it possible with the integrated webserver to > have the script at /? If "script_names" is set to "/", > the url is localhost//name. If it is not given or "", > I always get 404 for every url. > Yes: http://cppcms.com/wikipp/en/page/run_application_web_server_root Specifically: http://cppcms.com/wikipp/en/page/run_application_web_server_root#CppCMS-Embedded > Is it possible to reconfigure the internal file server > to be at another root? You mean "document root"? Yes: http://cppcms.com/wikipp/en/page/cppcms_1x_config#file_server.document_root Also you may be interested in aliases: http://cppcms.com/wikipp/en/page/cppcms_1x_config#file_server.alias > > I am afraid I do not fully understand the url mapper. > E.g. I have: > > 27 attach (new Base_gui(srv), > 28 "gui", "/gui{1}", > 29 "/gui(/(.*))?", 1); > 30 > 31 attach (new Base_rpc(srv), > 32 "rpc", "/rpc{1}", > 33 "/rpc(/(.*))?", 1); > > > For any reason > > 52 << "<a href='" << > url("gui")<< "'>GUI</a><br>" > 53 << "<a href='" << > url("rpc")<< "'>RPC</a><br> > > works for gui, but not for rpc? See following error for rpc: > > 2012-03-01 15:46:48; cppcms, error: url_mapper: key `' not found for url > `gui' > > [...] > > Sorry for all topics in one mail. > Best regards > > Markus Raab > Because when you map sub-application and refer to it you automatically referred to the default URL of the sub-application - empty one "empty key" See: http://cppcms.com/cppcms_ref/latest/classcppcms_1_1url__mapper.html#a249e59de419f7fd0241cab6634c68393 Also I'd recommend to update to CppCMS 1.0.0 as in latest version exception is not thrown in case of invalid URL but rather "/this_is_invalid_url" some something like that generated. Regards, Artyom |