Re: [Cppcms-users] URL dispatching help
Brought to you by:
artyom-beilis
|
From: Troy W. <dr...@gm...> - 2013-05-03 08:40:29
|
<digression>
> 1. Read the docs.
I have read both the tutorials online and the API documentation generated
by Doxygen. The documentation is riddled with spelling
and grammatical errors making it difficult for me to comprehend in some
places.
> 2. Read existing code and examples.
You must have missed earlier where I mentioned reading the examples and
looking through the code and not understanding the concept or use of the
url_mapper class! That's why I'm here asking people who do understand it,
hoping they can share some knowledge! The help so far is VERY appreciated.
:)
> It is a walk in park if you already know C++...
I do.
> ... and some basic web programming.
I don't. The documentation fails to educate a person new to web
development, like me.
</digression>
Anyway, back on topic:
I think I'm not understanding HOW to use the url_mapper class because I
don't understand WHY I would need to or should. What problem does it solve?
Like I said above, I'm new to web programming. In a project larger than
CppBlog and WikiPP I'm not using the URL mapping functions anywhere, which
leads me to believe that either it's useless or, more likely, I'm doing
something wrong! :)
According to a simple "grep -R mapper()", the url_mapper member of the
application class is referred to 52 times in all the examples code and
WikiPP and CppBlog code. Of those 52 uses, only seven are not a call to
mapper().assign(...). Five are to mapper().root(...) and the remaining two
are for mapper().set_value(...). I use none of those in my code, or any
other call to mapper(), yet the application seems to work so far!
Perhaps the problem is that I'm generating all the HTML code in CppCMS
templates and none in C++ functions. Is URL mapping relevant if I'm only
using templates to output HTML? I assume it is, because the documentation
states:
Such system allows using "url" tag in templates system easily as"
<a href="<% url "/news/article" using article id %>" >...</a>
But I've been using something like:
<a href="/news/<%= article.id %>">...</a>
Which appears to work fine. I'm presuming there's some problem in my usage
that URL mapping solves?
Thank you all for being patient with me and helping where you can!
On Fri, May 3, 2013 at 1:36 AM, Shiv Shankar Dayal <
shi...@gm...> wrote:
> Two things. 1. Read the docs. 2. Read existing code and examples. It is a
> walk in park if you already know C++ and some basic web programming.
>
>
> On Thu, May 2, 2013 at 9:04 PM, Shiv Shankar Dayal <
> shi...@gm...> wrote:
>
>> look up examples directory in cppcms directory. you need cppdb for some
>> apps. you can also install cppwiki and cppblog for more understanding. It
>> is all there for you.
>>
>>
>> On Thu, May 2, 2013 at 1:08 PM, Troy Watson <dr...@gm...> wrote:
>>
>>> Nope - still not getting it :(
>>>
>>> Perhaps if you can spare some time to show me with a real, practical
>>> example I'll understand.
>>>
>>> I have the following line in my code: dispatcher().assign(
>>> "/edit/(\\d+)", &application::edit_bookmark, this, 1 );
>>> It correctly calls this function:
>>>
>>> void edit_bookmarks( std::string id )
>>>
>>> ...when I click links that look like /edit/10 or /edit/9239 etc.
>>> Dispatching I understand.
>>>
>>> Where does mapping come into this? How can my application be improved
>>> with a call to mapper(...)? How could it compliment the dispatcher as shown
>>> above?
>>>
>>>
>>>
>>>
>>> On Wed, May 1, 2013 at 12:59 AM, Shiv Shankar Dayal <
>>> shi...@gm...> wrote:
>>>
>>>> It is simple actually. You click a link some function on server is
>>>> invoked and output is displayed on another link. One is mapping another is
>>>> dispatching.
>>>>
>>>>
>>>> Best regards,
>>>> Shiv
>>>>
>>>>
>>>> On Tue, Apr 30, 2013 at 2:16 PM, Troy Watson <dr...@gm...> wrote:
>>>>
>>>>> I've read that page several times, messed about with the url_mapping
>>>>> example, and it still makes no sense to me what you mean by "the opposite
>>>>> of dispatching". I appreciate the help, but please explain it like I've
>>>>> never written a webapp before... because I haven't!
>>>>>
>>>>>
>>>>> On Mon, Apr 29, 2013 at 4:28 PM, Artyom Beilis <art...@ya...>wrote:
>>>>>
>>>>>> > What is mapper().assign( "...", "..." ) used for? All my URL
>>>>>> dispatching seems to work by only calling
>>>>>> > dispatcher().assign(...) to set up the URLs with a callback
>>>>>> function.
>>>>>> > What concept am I not understanding that would require the mapper()?
>>>>>>
>>>>>> The opposite of dispatching :-)
>>>>>>
>>>>>>
>>>>>> See: http://cppcms.com/wikipp/en/page/cppcms_1x_tut_url_mapping
>>>>>>
>>>>>>
>>>>>>
>>>>>> Artyom Beilis
>>>>>> --------------
>>>>>> CppCMS - C++ Web Framework: http://cppcms.com/
>>>>>> CppDB - C++ SQL Connectivity: http://cppcms.com/sql/cppdb/
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Try New Relic Now & We'll Send You this Cool Shirt
>>>>>> New Relic is the only SaaS-based application performance monitoring
>>>>>> service
>>>>>> that delivers powerful full stack analytics. Optimize and monitor your
>>>>>> browser, app, & servers with just a few lines of code. Try New Relic
>>>>>> and get this awesome Nerd Life shirt!
>>>>>> http://p.sf.net/sfu/newrelic_d2d_apr
>>>>>> _______________________________________________
>>>>>> Cppcms-users mailing list
>>>>>> Cpp...@li...
>>>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
>>>>> Get 100% visibility into your production application - at no cost.
>>>>> Code-level diagnostics for performance bottlenecks with <2% overhead
>>>>> Download for free and get started troubleshooting in minutes.
>>>>> http://p.sf.net/sfu/appdyn_d2d_ap1
>>>>>
>>>>> _______________________________________________
>>>>> Cppcms-users mailing list
>>>>> Cpp...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Best regards,
>>>> Shiv Shankar Dayal
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
>>>> Get 100% visibility into your production application - at no cost.
>>>> Code-level diagnostics for performance bottlenecks with <2% overhead
>>>> Download for free and get started troubleshooting in minutes.
>>>> http://p.sf.net/sfu/appdyn_d2d_ap1
>>>> _______________________________________________
>>>> Cppcms-users mailing list
>>>> Cpp...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
>>> Get 100% visibility into your production application - at no cost.
>>> Code-level diagnostics for performance bottlenecks with <2% overhead
>>> Download for free and get started troubleshooting in minutes.
>>> http://p.sf.net/sfu/appdyn_d2d_ap1
>>> _______________________________________________
>>> Cppcms-users mailing list
>>> Cpp...@li...
>>> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>>>
>>>
>>
>>
>> --
>> Best regards,
>> Shiv Shankar Dayal
>>
>
>
>
> --
> Best regards,
> Shiv Shankar Dayal
>
>
> ------------------------------------------------------------------------------
> Introducing AppDynamics Lite, a free troubleshooting tool for Java/.NET
> Get 100% visibility into your production application - at no cost.
> Code-level diagnostics for performance bottlenecks with <2% overhead
> Download for free and get started troubleshooting in minutes.
> http://p.sf.net/sfu/appdyn_d2d_ap1
> _______________________________________________
> Cppcms-users mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppcms-users
>
>
|