I want only one application to be hosted on my site and I want to keep
my urls clean. So instead of having url 
http://crm.appspot.com/crm/default/list_persons,
I want to have url like http://crm.appspot.com/list_persons. In order
to achieve this behavior, I wrote the routes.py as:

# routes.py
import os, re

default_app = 'crm'

routes_in = []

regex = re.compile('^\w+$')
for app in os.listdir('applications'):
    if regex.match(app):
        routes_in.append(
            ('.*:/%s' % app, '/%s/default' % app)
        )
        routes_in.append(
            ('.*:/%s/(?P<path>.*)' % app, '/%s/\g<path>' % app)
        )

routes_out = (
    ('/%s/static/(?P<path>.*)' % default_app, '/static/\g<path>'),
    ('/%s/default/(?P<path>.*)' % default_app, '/\g<path>'),
)

routes_in.extend(
    [
    ('.*:' + y.replace('\g<path>', '(?P<path>.*)'), \
        x.replace('(?P<path>.*)', '\g<path>') \
    ) for (x, y) in routes_out
    ]
)

Its working very good for me. And I can browse the list_companies page
with both http://crm.appspot.com/crm/default/list_companies and
http://crm.appspot.com/list_companies.
Does it have any performance overhead? Else why the routes.py is not
preferred?
-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.


Reply via email to