On 13 Jun 2013, at 5:04 AM, Júlia Rizza <[email protected]> wrote: > I was reading about the specific routes of applications in the book section > Application-Specific URL rewrite, but didn't understand well how it works. > Could someone explain for me how routes_app create a routes.py specific in > each app and, if possible, give me an example? > >
Ordinarily, there's a single routes.py that lives in the web2py root. There's an option to put an app's routing rules instead in the apps base directory. There are at least two motivations for doing so: the app's internal routing can be part of the app, and more easily distributed and installed, and it can be simpler than a root routes.py that needs to route multiple apps with different internal rules. So we can have a routes.py per app, located in that app's own base directory. But in order to do that, web2py still needs a root routes.py with a rule that tells it *which* app-specific routes.py to use for an incoming URL. In the pattern-based router, that rule is named routes_app. It's similar in syntax to routes_in, but it produces an app name, not a new URL. You'll find an example routes_app in routes.example.py, and a unit test it gluon/tests/test_routes.py. (Note that the parametric router takes a different approach, and does not employ routes_app.) -- --- 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/groups/opt_out.

