On 31 Jul 2012, at 4:29 PM, Marek Mollin <[email protected]> wrote:
> I have certain problems configuring router + routes.py.
> First of all I had a problem that was mentioned earlier routes.py file was 
> not working while using nginx + uwsgi. Nevertheless I decided to update to 
> trunk and just copied admin from stable (since there were some problems with 
> it... not important)
> 
> My setup is.
> At the moment I have one domain... so if I want I can just define routes_in 
> and out in main file.
> But I decided to actually prepare the whole thing for other websites thus 
> using the router + routes.py(app specific).
> I have a file routes.py in main web2py folder and it reads as this:
> 
> routers = dict(
>         BASE = dict(
>                 domains = {
>                        'menzo.pl:80' : 'menzo',
>                        'menzo.pl:443' : 'menzo'
>                 },
>                 default_application = 'menzo',
>                 applications = ['menzo','admin'],
>                 controllers = 'DEFAULT',
>                 map_static = True
>         ),
> )
> 
> How this configuration affects local(app) routes.py if at all.
> Cause I have in ma app routes.py
> 
> routes_in = (
>         ('/admin/$anything', '/admin/$anything'),
>         ('/static/$anything', '/menzo/static/$anything'),
>         ('/produkty/$a','/menzo/produkty/index/$a'),
> )
> 
> routes_out = [(x, y) for (y, x) in routes_in[:-2]]
> 
> 
> admin working fine
> static working fine
> the third line not really working.
> 
> Just to give more context.
> I have controller produkty.py with index function (which I would like to 
> omit).
> Controller does not have any other functions inside. I am aware it can be 
> move to default.py and will work out of the box, but I just would like to 
> know for future reference if I am doing anything wrong.
> 
> I tested the whole section with r'strings' but with same results.
> 

In brief, the two flavors of routing don't mix. I think that routes_in is 
simply being ignored, and what you see working fine is the parametric router. 
So the trick is to get the router to omit 'index' from the produkty controller.

routers = dict(
        BASE = dict(
                domains = {
                       'menzo.pl:80' : 'menzo',
                       'menzo.pl:443' : 'menzo'
                },
                default_application = 'menzo',
                applications = ['menzo','admin'],
                controllers = 'DEFAULT',
                map_static = True
        ),
        menzo = dict(
                functions = dict(
                        produkty=['index', 'other', 'functions'],
                        default=['index', 'user', 'more',],
                ),
        ),
)

A couple of observations. You don't really need to list the functions in 
default. You need to list *all* the (visible) functions in produkty, so the 
router can tell when it's safe to omit 'index'. Also, there's probably no 
reason for the domains map (I think), since your default application is already 
menzo. What the domains map does (mostly, anyway) is to let you have per-domain 
default applications.

-- 



Reply via email to