[FIX] website: exception handling: let redirects pass untouched

The website module normally tries to render user-friendly
error pages for any error occurring during the processing
of a website-enabled request.
This happens even for werkzeug's HTTPExceptions that have
their own response, because we want the website layout to
be applied on top of the error page.

One special sort of HTTPException should be preserved
without rewriting: the manually-crafted ones generated
with abort(), and usually wrapping a redirect response,
which bears no alteration.
This commit is contained in:
Olivier Dony 2014-06-27 12:56:24 +02:00
parent 7e9dfa774e
commit a7aa853737
1 changed files with 5 additions and 0 deletions

View File

@ -127,6 +127,11 @@ class ir_http(orm.AbstractModel):
if isinstance(exception.qweb.get('cause'), openerp.exceptions.AccessError):
code = 403
if isinstance(exception, werkzeug.exceptions.HTTPException) and code is None:
# Hand-crafted HTTPException likely coming from abort(),
# usually for a redirect response -> return it directly
return exception
if code == 500:
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
if 'qweb_exception' in values: