Hi Anthony, /errors/index function is a simple:
def index():
#response.status = request.vars.code
return dict(vars=request.vars)
Notice the response.status line commented, it's the one triggering the
loop.
The template is very simple, in fact I simulated all kinds of error
and it gets rendered correctly. It's only setting the status on the
controller (the commented line in the index() function) that triggers
the infinite loop.
routes_onerror is exactly as reported, with the leading '/'.
BTW, I'm using 1.99.2
feel free to suggest anything you want, I'm happy to test it
heavily :D
feel free to suggest anything you want, I'm happy to test it
heavily :D
Thanks
Niphlod
These settings for production sites are a real deal, so, here we
are...
The test is a basic app, with an errors/index function expressed as:
def index():
response.status = request.vars.code
return dict(vars=request.vars)
The test is "passed" when:
a) the appname is stripped from the url
b) the error handler doesn't loop forever
c) a request made to http://host.domain/robots.txt returns the
contents of appname/static/robots.txt
d) a request made to http://host.domain/favicon.ico returns the
contents of appname/static/favicon.ico
e) a request made to http://host.domain/sitemap.xml returns the
contents of appname/static/sitemap.xml
TEST 1:
---routes.py---
default_application = 'appname'
routes_onerror = [
('*/*', '/appname/errors/index')
]
results : a) not working (that's expected), b) working, c), d), e) not
working (expected behaviour)
TEST 2:
---routes.py---
default_application = 'appname'
routers = dict(
BASE = dict(
default_application = 'appname',
),
)
routes_onerror = [
('*/*', '/errors/index')
]
results: a) working, b) working, c) working, d) working, e) not
working
---routes.py---
default_application = 'appname'
routes_in = (
('/robots.txt', '/static/robots.txt'),
('/sitemap.xml', '/static/sitemap.xml'),
('/favicon.ico', '/static/favicon.ico'),
)
routes_out = (
('/static/robots.txt', '/robots.txt'),
('/static/sitemap.xml', '/sitemap.xml'),
('/static/favicon.ico', '/favicon.ico'),
)
routers = dict(
BASE = dict(
default_application = 'appname',
),
)
routes_onerror = [
('*/*', '/errors/index')
]
results: a) working, b) working, c) working, d) working, e) not
working
TEST 3:
---routes.py---
default_application = 'appname'
routes_in = (
('/(?P<any>.*)', '/appname/\g<any>'),
('/favicon.ico', '/appname/static/favicon.ico'),
('/sitemap.xml', '/appname/static/sitemap.xml'),
('/robots.txt', '/appname/static/robots.txt')
)
routes_out = (
('/appname/(?P<any>.*)', '/\g<any>'),
('/appname/static/favicon.ico', '/favicon.ico' ),
('/appname/static/robots.txt', '/robots.txt'),
('/appname/static/sitemap.xml', '/sitemap.xml')
)
routes_onerror = [
('*/*', '/errors/index')
]
results: a) working, b) working, c) working, d) working, e) not
working
TEST 4:
default_application = 'appname'
routes_in = (
('/favicon.ico', '/appname/static/favicon.ico'),
('/robots.txt', '/appname/static/robots.txt'),
('/sitemap.xml', '/appname/static/sitemap.xml'),
('/(?P<any>.*)', '/appname/\g<any>')
)
routes_out = (
('/appname/static/favicon.ico', '/favicon.ico' ),
('/appname/static/robots.txt', '/robots.txt'),
('/appname/static/sitemap.xml', '/sitemap.xml'),
('/appname/(?P<any>.*)', '/\g<any>')
)
results: a) working, b) working, c) working, d) working, e) working
So, to sum up, something I think I have learned from the experience:
- pattern-based and parameter-based aren't meant to use together. With
pattern-based system "root files" as robots.txt and favicon.ico are
handled internally but not sitemap.xml (or anything else)
- routes_onerror seems to work independantly of the "rewrite method"
- in pattern-based system the order matters. This is an expected
behaviour but nonetheless worth to remember. As an example, take TEST
3 and TEST 4... sitemap.xml gets "taken" by the ('/(?P<any>.*)', '/
appname/\g<any>') tuple in TEST 3 before the "exact match".
- parameter-based is really helpful to map domains to apps or if you
have multiple apps but only one "preferred", or with language-based
redirections. With parameter-based system you can access other apps by
"normal" non-rewritten urls. With pattern-based if you want to have a
"default" application you have to map any additional application
specifically.
> > c) a request made tohttp://host.domain/robots.txtreturns the
> > contents of appname/static/robots.txt
> > d) a request made tohttp://host.domain/favicon.icoreturns the
> > contents of appname/static/favicon.ico
> > e) a request made tohttp://host.domain/sitemap.xmlreturns the
yes, as far as I can tell the patch solved the infinite loop problem.
All other things are working correctly: it did not brake anything as
far as my tests gone.