Another issue with url_for is the handling of query string parameters
using keyword arguments. Currently any extra keyword arguments will be
added to the generated URL as query string, for example:
url_for('/page', arg='val') ==> /page?arg=val
The problem is that you can't use keyword arguments for any of the
argument names reserved by the function, such as "host", "protocol",
etc, for example:
params = { 'arg': 'val', 'host': 'machine' }
url_for('/page', **params)
should return:
/page?arg=val&host=machine
but it treats the "host" key in params as the host name so it actually
returns:
http://machine/page?arg=val
On Jan 4, 2:29 pm, Tycon <[email protected]> wrote:
> from the "url_for" doc string :
>
> If no route by that name is found, the string is assumed to be a
> raw URL.
> Should the raw URL begin with ``/`` then appropriate SCRIPT_NAME
> data will
> be added if present, otherwise the string will be used as the url
> with
> keyword args becoming GET query args.
>
> But what if I don't want to SCRIPT_NAME to be prefixed to the URL
> because it's a link for a different application ? For example if
> pylons app has SCRIPT_NAME of "/pylons" but I want to create a URL for
> "/blog/newposts" which is served an a different blog application (so
> it should not be converted to /pylons/blog/newposts) ?
>
> Normally I wouldn't need to call url_for in this case, and just use
> the external URL directly, but
> if I need to do a redirect using pylons redirect_to it will
> internally call url_for and add the SCRIPT_NAME
> prefix.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---