[pylons-discuss] strategies for multiple similar routes to a single view

2014-10-15 Thread Jonathan Vanasco
i'm using url dispatch , and I have some routes that begin with this: /by/{username:\w+} i now need to support 'id' based urls as well. e.g. /by/{userid:\-\d+} the regexes are actually more complicated, and defined elsewhere. there is an approach i think I'd like to pursue, and

Re: [pylons-discuss] strategies for multiple similar routes to a single view

2014-10-15 Thread Michael Merickel
When defining a route, there are several hooks available to you to configure custom behaviors. 1) The route pattern. 2) Route predicates. 3) Route factory. You basically touched on all of these in your examples. It's usually advantageous to have a single route, so let's ignore the pattern

Re: [pylons-discuss] strategies for multiple similar routes to a single view

2014-10-15 Thread Jonathan Vanasco
Thanks! It looks like Route Factory is what I want. The docs are pretty sparse on it (at least on http://docs.pylonsproject.org/docs/pyramid/en/latest/narr/urldispatch.html) I'll look up some examples in public Pyramid projects and blogs later. I didn't realize that I could affect the dict

Re: [pylons-discuss] strategies for multiple similar routes to a single view

2014-10-15 Thread Michael Merickel
Predicates should return True or False. They have no sense of locality, so if you mess with the request and return True, and another predicate returns False then you have screwed up the request for some subsequent route that may match. This is obviously not ideal, but will work in 95% of apps.