I meant "global by default". I was aware of the existence of the
"routes_app" parameter. But my point here was more specifically about this
mechanism not being used for welcome and example apps by default. This and
lack of documentation in book makes it almost non-existing for users.
It would be nice to improve on this with the new routes and have the
app-specific routes for one of the apps and default ones for the other. I
know both welcome and examples apps don't need any special routes
configuration, but to demonstrate how to use the routes one of the apps
could have its local routes defined. And I mean here some kind of example
urls not neccessery used anywhere in the app. Just to let users learn the
routes mechanism by example.
It is indeed a bit problematic to keep the user routes and the default
routes separated. As Jonathan suggested, having routes.standard.py loaded
when no routes.py is present might be a solution. Alternative would be to
have routes.example.py which is not loaded at all and serves as example
only. In both cases however, there should be the "demo" routes.py inside
i.e. examples app folder.
I must admit that I missed the RC thread when I was writing my comments here
and I didn't understood well the concept of new routes. After reading more
and giving some thought into how the new system works I think Jonathan did a
really good job. New routes seems to tackle almost all practically useful
cases and are easier to use and customise.
To visualise that better let me specify some examples from my own routes
which are already covered:
(".*:/favicon.ico", "/init/static/favicon.ico") - covered by default
(root_static key)
(".*:/robots.txt", "/init/static/robots.txt") - covered by default
(root_static key)
("/", "/init/default/index") - covert by default (default_controller and
default_function keys)
("/(.+)", r"/init/\1") - covered by default (default_application key)
Now a few cases of url shortening that I'm using in old routes that maybe
are worth considering in the new one:
1) ("/(%s)" % "|".join(DEFAULTS), r"/init/default/\1") - DEFAULTS is the
list of functions in default controller (I want to skip the default
controller name in URL)
2) ("/f1/(.+)", r"/init/default/f2/\1") - skipping the controller and
mapping to a function in the default one (it can be turn into example 1 if
f1 == f2)
3) ("/label", "/init/default/func/arg1/arg2/arg3/arg4") - I want to link
with a short label to a deep element of the page
Other examples that I brought forward before might not be worth considering
as they are very specific and could be represented differently anyway:
e.g. /author/smith -> /init/default/author?name=smith
This is equal to ("/func/(.+)", r"/init/default/func?arg1=\1") and could be
("/func/(.+)", r"/init/default/func/\1") which is the same as example 1.
One last question, as this is not entirely clear for me. Can I use the new
routes to point to my app-specific routes defined with old routes regex
syntax? What about something like autoroutes routes.conf syntax? Wouldn't
that be useful to benefit from new routes and still have regex (although
simplified to local app-specific paths) as last resort?