I want to use app-specific routes to make my application more portable. 
Let's assume that there
is no "web2py/routes.py" file and my application name is "init". Now I 
created the "routes.py" file
in "web2py/applications/init/" directory and defined my simple router there:

my_router = dict(
  controllers = "DEFAULT",
  functions = ["about", "privacy", "api"],
  map_static = True,
)

My intention here was to make some URLs shorter:
/init/default/about <-> /about 
/init/static/css/print.css <-> /static/css/print.css

After reading the code of rewrite.py:load() I got an impression that I need 
to define this app-specific
router inside a "routers" dictionary. It doesn't make much sense for me, but 
so be it, I added:

routers = {"init":my_router}

However this doesn't work for the app-specific routes in 
"web2py/applications/init/routes.py".
On the other hand, it works when put in "web2py/routes.py" so I believe I 
didn't define the
router correctly.

As this is not documented precisely and the welcome or example apps have no 
app-level routes
defined either could you please share some more information/examples on 
this? I've tried to figure
out the mechanism from the code but the routes loading procedure is not the 
easiest one to follow :)

Reply via email to