How will a ":" help the case when I want to create a url for my non-
pylons blog like this:
params = {'id': 1234, 'host': 'junglekid' }
url = url_for('/blog/showpost', protocol='http', **params)
This SHOULD return:
http://www.mysite.com/blog/showpost?id=1234&host=junglekid
But currently, url_for will try to do the following unwanted things
for the above case:
1. It will try to match it against "named" routes and other stuff in
the routing map.
2. It will add the SCRIPT_NAME as a prefix.
3. If the params dict contains any duplicates or reserved keywords
(such as "host"), then it will be treated differently and not added to
the query string.
So to fix all these issues, the user can use the new raw, external,
and params arguments:
url = url_for('/blog/showpost', protocol='http', raw=True,
external=True, params=params)
On Jan 6, 10:33 am, "Mike Orr" <[email protected]> wrote:
> On Tue, Jan 6, 2009 at 10:07 AM, Ben Bangert <[email protected]> wrote:
> > On Jan 5, 2009, at 1:56 PM, Tycon wrote:
>
> >> right and don't forget about adding the new "raw" (to avoid mapper
> >> lookup if true) and "external" (to avoid adding SCRIPT_NAME prefix if
> >> true) arguments, in addition to the "params" dict, so you will have a
> >> much better url_for
>
> > One of your issues with proto, and host, was that you couldn't then use them
> > in Routes names. By adding three more, it means you can't have:
> > map.connect('/host/{raw}/{params}'), etc.
> > In addition to not having host, proto, etc.
>
> > So the routing section for Pylons users gets a longer list of reserved words
> > that can't be used, and host still can't be used. Was that the desired
> > result?
>
> Why are those names not allowed in the path? The issue isn't one of
> variable collisions but keyword arg collisions.
>
> Although I'm still not sure of the intrinsic merits of the 'raw' and
> 'external' proposals, which is why I wanted your opinion. In Routes
> 2, 'external' is marked at route definition, not in the URL call. And
> paths that contain a colon before any slash ("http:") are
> automatically marked external. So perhaps we want to avoid piling
> kludge upon kludge in Routes 1 to accomplish the same thing, which is
> my concern about 'raw' and 'external'.
>
> --
> Mike Orr <[email protected]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---