On Thu, Jun 4, 2009 at 12:45 PM, TJ Ninneman<t...@twopeasinabucket.com> wrote:
>
> I've noticed in Routes 1.10.3 that when url_for is called with
> arguments which are None, it goes ahead and puts the string 'None' in
> the generated URL.
>
> I needed this to change to avoid urls like:
>
> /shop/?source=34465&filters=&product=77987245
>
> or
>
> /shop/?source=34465&filters=None&product=77987245
>
> I went ahead and created a small patch file which checks if the var is
> None and if so, doesn't include it in the resultant URL.  Hope it
> helps if anybody needs it.
>
> http://www.pylonshq.com/pasties/9f17ba4998e211114343428f189286bc

url_for() is complicated so I'm not sure what it should do in all
cases.  Certainly it should never covert None to "None".  'filters='
is a valid empty value so there's nothing wrong with that, if we
assume that None should be taken as '', which I'm not sure about.  In
any case, we're trying to move users from url_for to pylons.url, which
is better implemented.

I have made my own proposal for a url.current_with_query() which would
reproduce the current URL with query, overriding query params via
keyword args, and deleting any param whose keyword arg is None.  That
would be consistent with your proposal.

However, it makes sense to delete query params whose values are None.
It does not make sense to accept None as an override to a path
variable.  Neither replacing it with None nor deleting it is
appropriate.  Instead, Routes should either raise an error or consider
the route a non-match to the arguments; I'm not sure which is better.

-- 
Mike Orr <sluggos...@gmail.com>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to