The {pattern} notation represents a segment in a URL which is separated by 
slashes. If you want to use multiple segments you should define them 
separately, ie /{one}/{two} or use the /path/to/*remainder notation to 
catch everything remaining. To generate a URL you can provide a tuple or a 
string, i.e.: request.route_url('test', testname='path/to/resource') or 
request.route_url('test', testname=('path', 'to', 'resource')). Any value 
you pass in your patterns will be url-quoted.

On Thursday, 21 February 2013 08:11:28 UTC-5, Simon King wrote:
>
> Hi all,
>
> I'm not sure if this would be considered a bug, but I'm having trouble 
> generating URLs using request.route_url, when my replacement values 
> themselves contain slashes. For example, if I had the following route 
> defined:
>
>   config.add_route('test', '/tests/{testname}/')
>
> and I generate a route like this:
>
>   request.route_url('test', testname='one/two')
>
> ...the resulting URL will look something like:
>
>   http://localhost/tests/one%2Ftwo/
>
> However, if I try to visit this URL, it is treated exactly the same as:
>
>   http://localhost/tests/one/two/
>
> ...so the route doesn't match. I suspect that as far as HTTP is concerned 
> those 2 URLs are equivalent, so my workaround will have to be escaping my 
> replacement values before creating URLs, and unescaping them in my views.
>
> Could this be considered a bug in route_url, that it generates URLs that 
> don't roundtrip correctly? And could it be fixed by adding special handling 
> of the "/" character in the generator and the matcher?
>
> Thanks,
>
> Simon
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to