From af3f56684f41884b5cf6fe0d4320c2f503705c4a Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Wed, 20 Aug 2014 15:24:34 +0200 Subject: [PATCH] [FIX] Do not assume all exceptions with a code attribute to be HTTPExceptions --- addons/website/models/ir_http.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index 76386f03b90..0ce1c0fe361 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -190,7 +190,14 @@ class ir_http(orm.AbstractModel): exception=exception, traceback=traceback.format_exc(exception), ) - code = getattr(exception, 'code', code) + + if isinstance(exception, werkzeug.exceptions.HTTPException): + if exception.code is None: + # Hand-crafted HTTPException likely coming from abort(), + # usually for a redirect response -> return it directly + return exception + else: + code = exception.code if isinstance(exception, openerp.exceptions.AccessError): code = 403 @@ -200,11 +207,6 @@ 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: