On Nov 19, 2010, at 2:26 PM, Alexandre Conrad wrote:

> I don't feel I'd use that very much. It's like having globals set in
> your app, you don't really know what's happening (even though the
> context manager helps in readability). I'd rather have explicitly
> {id:int} so I am sure it is casted to whatever the "int" named
> converter returns. You know what each route does just by looking at
> it.

The context manager would be required both to declare what converters are valid 
for the scope, but also because this functionality comes from another package 
in addition to pyramid you need to do something to get a different object with 
add_route/add_handler.

For non-context use, it'd be something like:

r = routehelper(config, converters=dict(int=converter.Integer(), 
month=converter.Integer(min=1, max=12))
r.add_handler('articles', '/articles/{action}/{id:int}', handler=....)
r.add_handler('month_archives', '/archives/{month:month}'...)

That last line is where people's custom converter names vs the marker names 
might get a little odd, which is why I was thinking one could assign a 
converter that would be used if the marker name was the same. Otherwise for 
clarity you'd prolly have this instead:

r = routehelper(config, converters=dict(int=converter.Integer(), 
month_conv=converter.Integer(min=1, max=12))
r.add_handler('month_archives', '/archives/{month:month_conv}'...)

Which I guess is fine, and as you mention it does avoid the ambiguity by making 
it explicit that something else is happening with the marker.

I do anticipate ppl using the routehelper as a 'partial', which is why many 
like the context manager aspect, like how Routes has a submapper:
http://routes.groovie.org/setting_up.html#submappers

Cheers,
Ben

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-de...@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