Thread: [Cppcms-users] What exactly url_mapper does?
Brought to you by:
artyom-beilis
From: Abhishek K. <abh...@gm...> - 2011-08-04 13:48:38
|
Hi, I have been going with the examples and documentations. I fully understand the functionlity of url_dispatcher, like how it links to applications functions filtering it from regex and passing the filtered value as parameters (I am referring the dispatcher.assign() function here). I am still not able to make any clue about url_mapper (mapper.assign() actually). I have been seeing it to be used in with dispatcher function, is it mandatory? does the mapper function as to be used along with dispatcher? Can you explain in the very simplest term & example, what exactly url_mapper does? and how can it be similar and different from dispatcher? Thanks Abhishek Kaushik |
From: Abhishek K. <abh...@gm...> - 2011-08-04 14:23:14
|
For Example: flat_thread::flat_thread(cppcms::service &s) : thread_shared(s) { dispatcher().assign(".*",&flat_thread::prepare,this,0); mapper().assign("{1}"); } Here I am not able to understand the role of mapper().assign("{1}") I able to understand dispatcher().assign() is trying to assign the matched urls to prepare function of flat thread with 0th parameter. Is mapper().assign() ignorable here? Please enlighten :( thanks Abhishek Kaushik |
From: Artyom B. <art...@ya...> - 2011-08-04 19:21:59
|
----- Original Message ----- > From: Abhishek Kaushik <abh...@gm...> > To: cpp...@li... > Cc: > Sent: Thursday, August 4, 2011 5:22 PM > Subject: Re: [Cppcms-users] What exactly url_mapper does? > > > > For Example: > > > flat_thread::flat_thread(cppcms::service &s) > : thread_shared(s) > { > dispatcher().assign(".*",&flat_thread::prepare,this,0); > mapper().assign("{1}"); > } > > Here I am not able to understand the role of > mapper().assign("{1}") I able to understand > dispatcher().assign() > is trying to assign the matched urls > to prepare function of flat thread with 0th parameter. > > Is mapper().assign() ignorable here? > > Please enlighten :( > thanks > Abhishek Kaushik > > Generally mapper is opposite of dispatcher: dispatcher: URL -> application mapper: "application" (by name) -> URL Read this: http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1url__mapper.html#_details Unfortunately there is no url mapping tutorial yet, but the reference documentation of this feature should be quite full. Also take a look on message board example in the sources for use of URL mapper. Ask again if you have further questions after reading this. Artyom |
From: 陈抒 <csf...@gm...> - 2011-08-05 03:42:19
|
Who can tell me how to write an regular expression for the following URL? http://localhost/search/village?x=1&y=2 ? is a big problem,I tried \\?,but it doesn't work. 陈抒 Best regards http://blog.csdn.net/sheismylife On Fri, Aug 5, 2011 at 3:21 AM, Artyom Beilis <art...@ya...> wrote: > ----- Original Message ----- > > > From: Abhishek Kaushik <abh...@gm...> > > To: cpp...@li... > > Cc: > > Sent: Thursday, August 4, 2011 5:22 PM > > Subject: Re: [Cppcms-users] What exactly url_mapper does? > > > > > > > > For Example: > > > > > > flat_thread::flat_thread(cppcms::service &s) > > : thread_shared(s) > > { > > dispatcher().assign(".*",&flat_thread::prepare,this,0); > > mapper().assign("{1}"); > > } > > > > Here I am not able to understand the role of > > mapper().assign("{1}") I able to understand > > dispatcher().assign() > > is trying to assign the matched urls > > to prepare function of flat thread with 0th parameter. > > > > Is mapper().assign() ignorable here? > > > > Please enlighten :( > > thanks > > Abhishek Kaushik > > > > > > Generally mapper is opposite of dispatcher: > > dispatcher: URL -> application > mapper: "application" (by name) -> URL > > > Read this: > > > http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1url__mapper.html#_details > > Unfortunately there is no url mapping tutorial yet, but the reference > documentation of this feature should be quite full. > > Also take a look on message board example in the sources for use > of URL mapper. > > Ask again if you have further questions after reading this. > > Artyom > > > ------------------------------------------------------------------------------ > BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA > The must-attend event for mobile developers. Connect with experts. > Get tools for creating Super Apps. See the latest technologies. > Sessions, hands-on labs, demos & much more. Register early & save! > http://p.sf.net/sfu/rim-blackberry-1 > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > |
From: Artyom B. <art...@ya...> - 2011-08-05 04:33:21
|
> > >Who can tell me how to write an regular expression for the following URL? >http://localhost/search/village?x=1&y=2 > > >? is a big problem,I tried \\?,but it doesn't work. > You don't! Read this: http://art-blog.no-ip.info/wikipp/en/page/cppcms_1x_tut_url_mapping > >陈抒 >Best regards >http://blog.csdn.net/sheismylife > > > >On Fri, Aug 5, 2011 at 3:21 AM, Artyom Beilis <art...@ya...> wrote: > >----- Original Message ----- >> >>> From: Abhishek Kaushik <abh...@gm...> >>> To: cpp...@li... >>> Cc: >>> Sent: Thursday, August 4, 2011 5:22 PM >>> Subject: Re: [Cppcms-users] What exactly url_mapper does? >>> >>> >>> >>> For Example: >>> >>> >>> flat_thread::flat_thread(cppcms::service &s) >>> : thread_shared(s) >>> { >>> dispatcher().assign(".*",&flat_thread::prepare,this,0); >>> mapper().assign("{1}"); >>> } >>> >>> Here I am not able to understand the role of >>> mapper().assign("{1}") I able to understand >>> dispatcher().assign() >>> is trying to assign the matched urls >>> to prepare function of flat thread with 0th parameter. >>> >>> Is mapper().assign() ignorable here? >>> >>> Please enlighten :( >>> thanks >>> Abhishek Kaushik >>> >>> >> >>Generally mapper is opposite of dispatcher: >> >>dispatcher: URL -> application >>mapper: "application" (by name) -> URL >> >> >>Read this: >> >> http://art-blog.no-ip.info/cppcms_ref_v0_99/classcppcms_1_1url__mapper.html#_details >> >>Unfortunately there is no url mapping tutorial yet, but the reference >>documentation of this feature should be quite full. >> >>Also take a look on message board example in the sources for use >>of URL mapper. >> >>Ask again if you have further questions after reading this. >> >>Artyom >> >>------------------------------------------------------------------------------ >>BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA >> >>The must-attend event for mobile developers. Connect with experts. >>Get tools for creating Super Apps. See the latest technologies. >>Sessions, hands-on labs, demos & much more. Register early & save! >>http://p.sf.net/sfu/rim-blackberry-1 >>_______________________________________________ >>Cppcms-users mailing list >>Cpp...@li... >>https://lists.sourceforge.net/lists/listinfo/cppcms-users >> > >------------------------------------------------------------------------------ >BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA >The must-attend event for mobile developers. Connect with experts. >Get tools for creating Super Apps. See the latest technologies. >Sessions, hands-on labs, demos & much more. Register early & save! >http://p.sf.net/sfu/rim-blackberry-1 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |
From: Abhishek K. <abh...@gm...> - 2011-08-05 08:14:59
|
Thanks for your reply Artyom, but as see, I have pasted the message_board app's url mapping code in my second post, and I have been going thru the reference for url_mapper too. but this word is not enough for me "url mapper is opposite of dispatcher" as I am not able to understand what the opposite could be. I am more keen about what exactly the void cppcms::url_mapper::assign function does with any simple example. I have seen the usage of this function in the message_board application, but I am not able to understand the exact purpose of it, as to what difference did it make. What change does this void cppcms::url_mapper::assign brings to the application. As I have mentioned already, I fully understand the dispatcher's assign function, but couldnt make any clue about mapper's assign function. thanks Abhishek |
From: Abhishek K. <abh...@gm...> - 2011-08-07 13:35:48
|
Hi, Could you please explain me these differences regarding the message board example application?: forums::forums(cppcms::service &srv) : master(srv) { dispatcher().assign(".*",&forums::prepare,this,0); mapper().assign("{1}"); // with id mapper().assign(""); // default } AND flat_thread::flat_thread(cppcms::service &s) : thread_shared(s) { dispatcher().assign(".*",&flat_thread::prepare,this,0); mapper().assign("{1}"); } I have referred the doxygen documentation, but still failed to make out much meaning regarding this particular problem. could you tell me as to why in forums constructor it was possible to have 2 mapper().assign() one for "" and other for "{1}" whereas, in flat_thread, it has only 1 mapper().assign() statement and thats "{1}". What conditions tell us that it would require 2 or 1 assign statements? I fully understand the dispatcher but this mapper, I am unable to. Hope you understand my problem. Please let me know if I am missing the basics of anything, i will refer it. Thanks in advance for your reply. |
From: Artyom B. <art...@ya...> - 2011-08-07 18:14:14
|
URL Mapper allows overloading the functions. For example you may call url("/my/app",category_id) and url("/my/app",category_id,page_no) That are mapped as map.assign("/app","/article/{1}") map.assign("/app","/article/{1}/page/{2}") In the case of main form page it just overloads the cases where the URL represents the latest comments or comments with paging. flat_thread::flat_thread(cppcms::service &s) : thread_shared(s) { dispatcher().assign(".*",&flat_thread::prepare,this,0); mapper().assign("{1}"); } Means that prepare function would receive as first parameter the 0 regular expression group on selection (Everything) and for mapping it would convert its parameter to its representation as is. Most important take a look on how URLs are used in templates forums.tmpl: <form action="<% url "/forums" %>" method="post" > forums.tmpl: <a href="<% url "/forums" using next %>"><% gt "Next Page" %></a> This is mapping of "forums" application with 0 or 1 parameter. And this is how thread applications mapping is used: thread.tmpl: <a href="<% url "/flat_thread" using thread_id %>"><% gt "Flat View"%></a> thread.tmpl: | <a href="<% url "/tree_thread" using thread_id %>"><% gt "Tree View" %></a> Regards, Artyom Beilis >________________________________ >From: Abhishek Kaushik <abh...@gm...> >To: cpp...@li... >Sent: Sunday, August 7, 2011 4:35 PM >Subject: Re: [Cppcms-users] What exactly url_mapper does? > >Hi, > >Could you please explain me these differences regarding >the message board example application?: > >forums::forums(cppcms::service &srv) : >master(srv) >{ > dispatcher().assign(".*",&forums::prepare,this,0); > mapper().assign("{1}"); // with id > mapper().assign(""); // default >} > >AND > >flat_thread::flat_thread(cppcms::service &s) : >thread_shared(s) >{ > dispatcher().assign(".*",&flat_thread::prepare,this,0); > mapper().assign("{1}"); >} > > >I have referred the doxygen documentation, but still failed to make out much >meaning regarding this particular problem. > >could you tell me as to why in forums constructor it was possible to have 2 >mapper().assign() one for "" and other for "{1}" > >whereas, in flat_thread, it has only 1 mapper().assign() statement >and thats "{1}". > >What conditions tell us that it would require 2 or 1 assign statements? > >I fully understand the dispatcher but this mapper, I am unable to. > >Hope you understand my problem. Please let me know if I am missing >the basics of anything, i will refer it. > >Thanks in advance for your reply. > > > > >------------------------------------------------------------------------------ >BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA >The must-attend event for mobile developers. Connect with experts. >Get tools for creating Super Apps. See the latest technologies. >Sessions, hands-on labs, demos & much more. Register early & save! >http://p.sf.net/sfu/rim-blackberry-1 >_______________________________________________ >Cppcms-users mailing list >Cpp...@li... >https://lists.sourceforge.net/lists/listinfo/cppcms-users > > > |