On Thursday, February 26, 2015 at 3:35:50 AM UTC-5, Louis Amon wrote: > > That’s actually what I ended up doing, but it isn’t something you can rely >> on in a big project… >> > > Why not? > > > Because you’d have to document very clearly the fact that some specific > rules need to be organized in a precise order among the list. > If you have hundreds of URLs managed in your routes.py and if 10 of them > need to be organized in specific orders then if you want to add an URL you > need a very clear view of exactly where you need to put the rule to match > it. > > Now imagine an intern takes over the routing… this whole order-based > routing would be an epic mess. >
That's entirely a function of the nature of your routing scheme and would apply to any pattern based system. An alternative is to come up with much more complicated regexes, but you still have the problem of needing to update the regexes as your app grows/changes. This is the advantage of keeping the routing more simple and straightforward (i.e., sticking with the default routing, plus some of the tweaks allowed by the parameter based system). > I was hoping there would be an alternative, but I guess regular >> expressions are indeed the only option to do things properly. >> > > Did you have a particular API in mind? The parameter-based system is > designed to be much simpler while cover the most common use cases, but if > you want something highly customized, there will inevitably be some > complexity to the rules you set up. > > > I was thinking about something like $args or $vars that would be pre-coded > with the right regex to match one or no args and/or a query string. > It would at least be helpful to document some examples of these patterns. Note, once you have the relevant regex, you can assign it to a variable in routes.py and re-use it. Anthony -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.

