I think autoroutes.py was developed before the newer parameter-based 
rewrite 
system<http://web2py.com/books/default/chapter/29/04#Parameter-based-system>-- 
you might find it easier to switch to that.

On Monday, April 29, 2013 9:25:33 PM UTC-4, Nikolay wrote:
>
> Hi Massimo,
>
> I use this. Correct, once using autoroutes (name to routes.py) I cannot 
> define custom error page no more. I of course get rid of un-needed stuffs))
>
> Please let me know of fix or new way for automatic routing. 
>
> config = '''
> 127.0.0.1   /path
> example.com /path
> '''
> if not config.strip():
>     try:
>         config = open('routes.conf','r').read()
>     except:
>         config=''
>
> #Setup Default
>
> def auto_in(apps):
>     routes = [
>         ('/robots.txt','/path/static/robots.txt'),
>         ('/favicon.ico','/path/static/favicon.ico'),
>         ('/sitemap.txt','/path/static/sitemap.txt'),
>         ('/admin$anything','/admin$anything'),
>         ]
>     for domain,path in [x.strip().split() for x in apps.split('\n') if 
> x.strip() and not x.strip().startswith('#')]:
>         if not path.startswith('/'): path = '/'+path
>         if path.endswith('/'): path = path[:-1]
>         app = path.split('/')[1]
>         routes += [
>             ('.*:https?://(.*\.)?%s:$method /' % domain,'%s' % path),
>             ('.*:https?://(.*\.)?%s:$method /static/$anything' % 
> domain,'/%s/static/$anything' % app),
>             ('.*:https?://(.*\.)?%s:$method /appadmin/$anything' % 
> domain,'/%s/appadmin/$anything' % app),
>             ('.*:https?://(.*\.)?%s:$method /$anything' % 
> domain,'%s/$anything' % path), 
>             ]
>     return routes
>
> def auto_out(apps):
>     routes = []
>     for domain,path in [x.strip().split() for x in apps.split('\n') if 
> x.strip() and not x.strip().startswith('#')]:
>         if not path.startswith('/'): path = '/'+path
>         if path.endswith('/'): path = path[:-1]
>         app = path.split('/')[1]
>         routes += [
>             ('/%s/static/$anything' % app,'/static/$anything'),
>             ('/%s/appadmin/$anything' % app, '/appadmin/$anything'),
>             ('%s/$anything' % path, '/$anything'),
>             ]
>     return routes
>
> routes_in = auto_in(config)
> routes_out = auto_out(config)
>
>

-- 

--- 
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