Thread: [Cppcms-users] Issues with resubmitting context in v1.2
Brought to you by:
artyom-beilis
From: CN <cn...@fa...> - 2016-06-08 10:09:03
Attachments:
t.cpp
|
Hi! Take "Resubmitting Context" in http://cppcms.com/wikipp/en/page/cppcms_1_2_filtering as an example. I encounter two issues as shown in the comments in "class part2". int main(int argc,char ** argv) { cppcms::service sv(argc,argv); booster::shared_ptr<cppcms::application_specific_pool> post_processor=cppcms::create_pool<part2>(); sv.applications_pool().mount(post_processor,cppcms::mount_point("/up2/(.+)",1),cppcms::app::synchronous); booster::weak_ptr<cppcms::application_specific_pool> p_post_processor(post_processor); sv.applications_pool().mount(cppcms::create_pool<part1>(p_post_processor),cppcms::mount_point("/up1",1),cppcms::app::asynchronous | cppcms::app::content_filter); ... } class part2 : public cppcms::rpc::json_rpc_server { private: void part2::main(std::string url) { //"up2/abc" instead of "abc" is logged: BOOSTER_DEBUG("url") << url; /* return_error() raises exception from cppcms::rpc::json_rpc_server::check_call() as follows: cppcms, error: Caught exception [JSON-RPC Request is not assigned to class] This error seems to not occur to this version: class part2 : public cppcms::application{} */ return_error(""); } public: part2(cppcms::service &s) : cppcms::rpc::json_rpc_server(s){} }; class part1 : public cppcms::application { private: booster::weak_ptr<cppcms::application_specific_pool> app_specific_pool; void main(std::string url); public: part1(cppcms::service &s,booster::weak_ptr<cppcms::application_specific_pool> app_specific_pool) : cppcms::rpc::json_rpc_server(s) { booster::shared_ptr<cppcms::application_specific_pool> pool=app_specific_pool.lock(); if(pool){ booster::shared_ptr<cppcms::http::context> ctx=release_context(); ctx->submit_to_pool(pool,"up2/abc"); } } }; A better formatted file is attached for your reference. Helps will be much appreciated. Best Regards, CN -- http://www.fastmail.com - mmm... Fastmail... |
From: Artyom B. <art...@gm...> - 2016-06-19 05:57:10
|
1st of all sorry for delayed reply - was offline for a while. Regarding your error - you had probably missed the concept of filter. Filter works BEFORE the data was uploaded processed. So you can do some stuff on the fly instead of downloading big content and discoverting an issue. You need to check if request().is_ready() and only than you can use it/forward it. Also JSON-RPC class does not support filer handling it is also not really needed. Artyom On Wed, Jun 8, 2016 at 1:08 PM, CN <cn...@fa...> wrote: > Hi! > > Take "Resubmitting Context" in > http://cppcms.com/wikipp/en/page/cppcms_1_2_filtering > as an example. I encounter two issues as shown in the comments in "class > part2". > > int main(int argc,char ** argv) > { > cppcms::service sv(argc,argv); > booster::shared_ptr<cppcms::application_specific_pool> > post_processor=cppcms::create_pool<part2>(); > sv.applications_pool().mount(post_processor,cppcms::mount_point("/up2/(.+)",1),cppcms::app::synchronous); > booster::weak_ptr<cppcms::application_specific_pool> > p_post_processor(post_processor); > sv.applications_pool().mount(cppcms::create_pool<part1>(p_post_processor),cppcms::mount_point("/up1",1),cppcms::app::asynchronous > | cppcms::app::content_filter); > > ... > } > > class part2 : public cppcms::rpc::json_rpc_server > { > private: > void part2::main(std::string url) > { > //"up2/abc" instead of "abc" is logged: > BOOSTER_DEBUG("url") << url; > /* > return_error() raises exception from > cppcms::rpc::json_rpc_server::check_call() > as follows: > > cppcms, error: Caught exception [JSON-RPC > Request is not assigned to class] > > This error seems to not occur to this version: > > class part2 : public cppcms::application{} > */ > return_error(""); > } > public: > part2(cppcms::service &s) > : cppcms::rpc::json_rpc_server(s){} > }; > > > class part1 : public cppcms::application > { > private: > booster::weak_ptr<cppcms::application_specific_pool> > app_specific_pool; > void main(std::string url); > public: > part1(cppcms::service > &s,booster::weak_ptr<cppcms::application_specific_pool> > app_specific_pool) > : cppcms::rpc::json_rpc_server(s) > { > booster::shared_ptr<cppcms::application_specific_pool> > pool=app_specific_pool.lock(); > if(pool){ > booster::shared_ptr<cppcms::http::context> > ctx=release_context(); > ctx->submit_to_pool(pool,"up2/abc"); > } > } > }; > > > A better formatted file is attached for your reference. > Helps will be much appreciated. > > Best Regards, > CN > > -- > http://www.fastmail.com - mmm... Fastmail... > > > ------------------------------------------------------------------------------ > What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic > patterns at an interface-level. Reveals which users, apps, and protocols are > consuming the most bandwidth. Provides multi-vendor support for NetFlow, > J-Flow, sFlow and other flows. Make informed decisions using capacity > planning reports. https://ad.doubleclick.net/ddm/clk/305295220;132659582;e > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: CN <cn...@fa...> - 2016-06-21 09:47:42
Attachments:
t.cpp
|
On Sun, Jun 19, 2016, at 01:57 PM, Artyom Beilis wrote: > 1st of all sorry for delayed reply - was offline for a while. I am very happy to know that you are back online, and much appreciate your kind helps! > > Regarding your error - you had probably missed the concept of filter. > Filter works BEFORE the data was uploaded processed. > So you can do some stuff on the fly instead of downloading big content > and discoverting an issue. > > You need to check if request().is_ready() and only than you can use > it/forward it. I understood its usage (finally). It was just because I somehow posted the wrong redacted sample program again (due to long-hour working?)! > Also JSON-RPC class does not support filer handling it is also not > really needed. Many thanks for the explanation! I am attaching new sample program. Hopefully it is the correct version I intend to use to illustrate my remaining question: Why part2::main(std::string url) gets string "up2/abc" instead of "abc"? It appears that regex group catching mechanism cppcms::mount_point("/up2/(.+)",1) is not invoked. Best Regards, CN ---------- int main(int argc,char ** argv) { cppcms::service sv(argc,argv); booster::shared_ptr<cppcms::application_specific_pool> p2=cppcms::create_pool<part2>(); sv.applications_pool().mount(p2,cppcms::mount_point("/up2/(.+)",1),cppcms::app::synchronous); booster::weak_ptr<cppcms::application_specific_pool> p_p2(p2); sv.applications_pool().mount(cppcms::create_pool<part1>(p_p2),cppcms::mount_point("/up1",1),cppcms::app::asynchronous | cppcms::app::content_filter); ... } class part2 : public cppcms::application { private: void part2::main(std::string url) { //QESTION: Why "up2/abc" instead of "abc" is logged? BOOSTER_DEBUG("url") << url; } public: part2(cppcms::service &s) : cppcms::application(s){} }; class part1 : public cppcms::application { private: booster::weak_ptr<cppcms::application_specific_pool> app_specific_pool; void main(std::string url) { if(!request().is_ready()){ //Do some pre-verification. } else{ booster::shared_ptr<cppcms::application_specific_pool> pool=app_specific_pool.lock(); if(pool){ booster::shared_ptr<cppcms::http::context> ctx=release_context(); ctx->submit_to_pool(pool,"up2/abc"); } } } public: part1(cppcms::service &s,booster::weak_ptr<cppcms::application_specific_pool> app_specific_pool) : cppcms::application(s){} }; -- http://www.fastmail.com - A no graphics, no pop-ups email service |
From: Artyom B. <art...@gm...> - 2016-06-25 13:29:02
|
Because when you call submit_to_pool you provide already parsed path - you don't submit it to general selection as you already know what pool you submit too. So you give the value that should be given to application::main so you need to call ctx->submit_to_pool(poo,"abc"); > > I am attaching new sample program. Hopefully it is the correct version I > intend to use to illustrate my remaining question: > > Why > part2::main(std::string url) > gets string "up2/abc" instead of "abc"? > > It appears that regex group catching mechanism > cppcms::mount_point("/up2/(.+)",1) > is not invoked. > > Best Regards, > CN > > if(!request().is_ready()){ > //Do some pre-verification. > } > else{ > booster::shared_ptr<cppcms::application_specific_pool> > pool=app_specific_pool.lock(); > if(pool){ > booster::shared_ptr<cppcms::http::context> > ctx=release_context(); > ctx->submit_to_pool(pool,"up2/abc"); > } > } |