On Tue, Jan 6, 2009 at 12:31 PM, Tycon <[email protected]> wrote:
>
> 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)
(1) would be solved by separating route lookups from literal URL
generation, for which Routes 2 has suggested something like
url.literal("/path", **params).
(2) is really a variation of an external URL, so I'm hesitant to add a
keyword arg just for it.
(3) is covered by the 'params' proposal.
Routes has several problems. Some of these have to be dealt with by
not using url_for() in certain edge cases, but just using a literal
URL. My concern is a long-term solution. If we add 'raw' and
'external' now, it will be a temporary kludge until Routes is
restructured, and then we'll either have to support it forever or
abandon it. Supporting it means bloated code and a convoluted API;
abandoning it means people would have to change their applications.
Vs the status quo of just not using url_for in certain situations.
The advantage of that is we aren't *adding* to the number of changes
people may have to make in the future when a long-term solution is
reached.
--
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
-~----------~----~----~----~------~----~------~--~---