On 20 Nov 2013, at 6:20 AM, lesssugar <[email protected]> wrote:

> Just let my understand it.
> 
> I created a basic routes.py file in my web2py/ folder. The whole content is:
> 
> default_application = 'myapp'    # ordinarily set in base routes.py
> default_controller = 'default'  # ordinarily set in app-specific routes.py
> default_function = 'index'      # ordinarily set in app-specific routes.py
> 
> When I go to mydomainname.com - default_application works fine.
> 
> But when I go directly to: mydomainname.com/myapp/users/index - the URL 
> remains unchanged.
> Shouldn't it be rewritten to: mydomainname.com/users ?
> 
> I mean, the default_application and default_function are set. Do I also need 
> to specify routes_in and _out for this?

I know that this is slightly confusing, but bear with me.

If there's no router specified in routes.py (or no routes.py) web2py makes 
assumptions about the default path if elements are missing. The built-in 
default is /init/default/index, and you can override that in routes.py without 
including an actual router (as in your example). When you do this, there is no 
rewriting (because there is no router).

If I understand your goal, you want something like this:

routers = dict(

    # base router
    BASE=dict(
        default_application='myapp',
    ),

    myapp=dict(
        default_controller = 'default'
        default_function = 'index'
    ),
)

Because you're not changing the *router* defaults for controller and function, 
you can just write this:

routers = dict(

    # base router
    BASE=dict(
        default_application='myapp',
    ),
)

...but I prefer to make things explicit.


-- 
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/groups/opt_out.

Reply via email to