[FIX] check after openerp's AccessErrors in website's _handle_exception
authorFabien Meghazi <fme@openerp.com>
Wed, 25 Jun 2014 10:20:40 +0000 (12:20 +0200)
committerFabien Meghazi <fme@openerp.com>
Wed, 25 Jun 2014 10:20:40 +0000 (12:20 +0200)
addons/website/models/ir_http.py

index be1e46f..d16077a 100644 (file)
@@ -98,7 +98,7 @@ class ir_http(orm.AbstractModel):
             werkzeug.exceptions.abort(werkzeug.utils.redirect(url))
 
     def _handle_exception(self, exception, code=500):
-        is_website_request = getattr(request, 'website_enabled', False) and request.website
+        is_website_request = bool(getattr(request, 'website_enabled', False) and request.website)
         if not is_website_request:
             # Don't touch non website requests exception handling
             return super(ir_http, self)._handle_exception(exception)
@@ -119,6 +119,9 @@ class ir_http(orm.AbstractModel):
             )
             code = getattr(exception, 'code', code)
 
+            if isinstance(exception, openerp.exceptions.AccessError):
+                code = 403
+
             if isinstance(exception, ir_qweb.QWebException):
                 values.update(qweb_exception=exception)
                 if isinstance(exception.qweb.get('cause'), openerp.exceptions.AccessError):