[IMP] Improved qweb exeptions handling

bzr revid: fme@openerp.com-20140130212053-fkb9ug49qun54ehi
This commit is contained in:
Fabien Meghazi
2014-01-30 22:20:53 +01:00
parent 895088a91a
commit 1931c307a2
2 changed files with 18 additions and 15 deletions
+6 -10
View File
@@ -103,20 +103,16 @@ class ir_http(orm.AbstractModel):
traceback=traceback.format_exc(exception),
)
if exception:
current_exception = exception
code = getattr(exception, 'code', code)
if isinstance(exception, ir_qweb.QWebException):
values.update(qweb_exception=exception)
if exception.inner:
current_exception = exception.inner
if isinstance(current_exception, openerp.exceptions.AccessError):
code = 403
else:
code = getattr(exception, 'code', code)
if isinstance(exception.qweb.get('inner'), openerp.exceptions.AccessError):
code = 403
if code == 500:
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
if values.get('qweb_exception'):
if 'qweb_exception' in values:
view = request.registry.get("ir.ui.view")
views = view._views_get(request.cr, request.uid, values['qweb_exception'].template, request.context)
views = view._views_get(request.cr, request.uid, exception.qweb['template'], request.context)
to_reset = [v for v in views if v.model_data_id.noupdate is True]
values['views'] = to_reset
elif code == 403:
@@ -132,7 +128,7 @@ class ir_http(orm.AbstractModel):
try:
html = request.website._render('website.%s' % code, values)
except:
except Exception:
html = request.website._render('website.http_error', values)
return werkzeug.wrappers.Response(html, status=code, content_type='text/html;charset=utf-8')
+12 -5
View File
@@ -451,7 +451,10 @@
<div id="error_main" class="panel-collapse collapse in">
<div class="panel-body">
<p t-if="website_controller">The following error was raised in the website controller <code t-esc="website_controller"/></p>
<p><strong>Error message:</strong> <pre t-esc="exception.message"/></p>
<p>
<strong>Error message:</strong>
<pre t-esc="exception.message"/>
</p>
</div>
</div>
</div>
@@ -466,11 +469,15 @@
<div id="error_qweb" class="panel-collapse collapse">
<div class="panel-body">
<p>
The error occured while rendering the template <code t-esc="qweb_exception.template"/>
<t t-if="qweb_exception.expression">and evaluating the following expression: <code t-esc="qweb_exception.expression"/></t>
<strong>Error message:</strong>
<pre t-esc="exception.qweb['message']"/>
</p>
<t t-if="qweb_exception.node">
<pre id="exception_node" t-esc="qweb_exception.node.toxml()"/>
<p>
The error occured while rendering the template <code t-esc="qweb_exception.qweb.get('template')"/>
<t t-if="'expression' in qweb_exception.qweb">and evaluating the following expression: <code t-esc="qweb_exception.qweb['expression']"/></t>
</p>
<t t-if="'node' in qweb_exception.qweb">
<pre id="exception_node" t-esc="qweb_exception.qweb['node'].toxml()"/>
</t>
</div>
</div>