After talking with Ben in IRC, we have come to the conclusion that
perhaps this could be considered a bug. Ben reckons he's going to make
a patch, but until then here is a little hack to make it work
def url_for_fix(*args, **kargs):
for key, val in kargs.items():
if isinstance(val, int):
kargs[key] = str(val)
return url_for(*args, **kargs)
just use this in place of url_for
ie.. import bla.url_for_fix as url_for
On Jul 25, 3:05 pm, Ben Bangert <[email protected]> wrote:
> On Jul 24, 2009, at 7:55 PM, The Devil's Programmer wrote:
>
>
>
> > #in my routes config
>
> > map.connect('/test', controller='test', action='test')
> > map.connect('/test', controller='test', action='test', page=1)
> > map.connect('/test/page{page:\d+}', controller='test', action='test')
>
> > #in my controller
>
> > print url_for(controller='test', action='test', page=1)
>
> > then i look at my debug and see /test/page1
>
> > when it should be /test
>
> > if i put quotes around the 1s to make them strings it works as i would
> > expect it to. so why is it incapable of comparing two integers?
>
> Well, you have some fairly ambiguous behavior by having two different
> routes on *exactly* the same URL only with different defaults. And the
> route choosing method in general is somewhat ambiguous on how it
> chooses, which is why you should *always* use named routes when you
> want to be 100% sure of which one is going to be used to generate a URL.
>
> I'm not 100% sure why adding the quotes makes it give you the URL you
> expect, as I mentioned, the whole scheme to try and figure it out is
> somewhat ambiguous. I'd welcome a patch that makes it do what you
> might expect (though I expect that'd make a fair amount of other use
> cases then work differently), but really, in the end, you should be
> using named routes.
>
> Cheers,
> Ben
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---