Happy to say this is now working.  One thing I was wondering is if the 
application specific url rewriting could route at the root level or not 
(e.g. route www.example.com/someapp/default/contat to 
www.example.com/contact) or if it was limited to having an app prefix (e.g. 
only route www.example.com/someapp/default/contact to 
www.example.com/someapp/contact).  Well I can confirm that it does not need 
an app prefix.

Here's what I put in <web2py-root>/routes.py assuming my app's name is 
"someapp":

# -*- coding: utf-8 -*-
# default_application, default_controller, default_function
# are used when the respective element is missing from the
# (possibly rewritten) incoming URL
#
default_application = 'someapp'    # 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
# routes_app is a tuple of tuples.  The first item in each is a regexp that 
will
# be used to match the incoming request URL. The second item in the tuple is
# an applicationname.  This mechanism allows you to specify the use of an
# app-specific routes.py. This entry is meaningful only in the base 
routes.py.
#
# Example: support welcome, admin, app and myapp, with myapp the default:

routes_app = ((r'/(?P<app>welcome|admin|app|someapp)\b.*', r'\g<app>'),
              (r'(.*)', r'someapp'),
              (r'/?(.*)', r'someapp'))


other than that I left routes_in and routes_out alone.

Then in my <web2py-root>/applications/someapp/routes.py I put:

default_controller = 'default'  # ordinarily set in app-specific routes.py
default_function = 'index'      # ordinarily set in app-specific routes.py

BASE = ''  # optonal prefix for incoming URLs

routes_in = (
    ('/(?P<function>about|contact)', r'/someapp/default/\g<function>'),
    # remove the BASE prefix
    (BASE + '/$anything', '/$anything'),
)
routes_out = (
    (r'/$app/default/index', '/'),
    (r'/$app/default/$anything', '/$anything'),
    # restore the BASE prefix
    ('/$anything', BASE + '/$anything'),
)
routes_onerror = [
    (r'*/*', r'/someapp/default/handle_error')
]


Not yet sure if the BASE stuff is necessary.  Also can confirm error 
routing works in the app specific routes.py with no error routes specified 
in the main routing file.

Note when I tried using the $app variable in routes_in as shown below it 
seemed to give a Rocket error

routes_in = (
    ('/(?P<function>about|contact)', r'/$app/default/\g<function>'),
    # remove the BASE prefix
    (BASE + '/$anything', '/$anything'),
)


I prefer the app specific routing because it makes it easy to version 
control your app's routes with your app's repository.

On Tuesday, January 28, 2014 11:25:07 PM UTC-5, User wrote:

> My <web2py-root>/routes.py currently has:
> # -*- coding: utf-8 -*-
>
>
>
> # default_application, default_controller, default_function
> # are used when the respective element is missing from the
> # (possibly rewritten) incoming URL
> #
> default_application = 'init'    # 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
>
> # routes_app is a tuple of tuples.  The first item in each is a regexp 
> that will
> # be used to match the incoming request URL. The second item in the tuple 
> is
> # an applicationname.  This mechanism allows you to specify the use of an
> # app-specific routes.py. This entry is meaningful only in the base 
> routes.py.
> #
> # Example: support welcome, admin, app and myapp, with myapp the default:
>
> routes_app = ((r'/(?P<app>welcome|admin|app)\b.*', r'\g<app>'),
>               (r'(.*)', r'myapp'),
>               (r'/?(.*)', r'myapp'))
>
> ...
>
> For a basic example of routing www.example.com/someapp/default/contact to 
> www.example.com/contact what needs to go in the <web2py-root>/routes.py 
> and what needs to go in the <web2py-root>/applications/someapp/routes.py?
>
> If I'm using application specific routing does this mean I should leave 
> routes_in and routes_out completely alone in <web2py-root>/routes.py?
>
> Also for specifying errors, do I use routes_onerror in 
> <web2py-root>/routes.py or <web2py-root>/applications/someapp/routes.py?
>
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to