[FIX] do not crash when trying to rescue a wrong t-call in template
Need trunk-website-al server's Rev#5173 bzr revid: fme@openerp.com-20140127114034-luhekopukpbmntqt
This commit is contained in:
parent
b8fec90fb4
commit
a2fb618354
|
@ -8,6 +8,7 @@ import werkzeug.routing
|
||||||
|
|
||||||
import openerp
|
import openerp
|
||||||
from openerp.addons.base import ir
|
from openerp.addons.base import ir
|
||||||
|
from openerp.addons.base.ir import ir_qweb
|
||||||
from openerp.addons.website.models.website import slug
|
from openerp.addons.website.models.website import slug
|
||||||
from openerp.http import request
|
from openerp.http import request
|
||||||
from openerp.osv import orm
|
from openerp.osv import orm
|
||||||
|
@ -109,21 +110,21 @@ class ir_http(orm.AbstractModel):
|
||||||
traceback=traceback.format_exc(exception),
|
traceback=traceback.format_exc(exception),
|
||||||
)
|
)
|
||||||
if exception:
|
if exception:
|
||||||
if isinstance(exception, openerp.exceptions.AccessError):
|
current_exception = exception
|
||||||
|
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
|
code = 403
|
||||||
else:
|
else:
|
||||||
code = getattr(exception, 'code', code)
|
code = getattr(exception, 'code', code)
|
||||||
values.update(
|
|
||||||
qweb_template=getattr(exception, 'qweb_template', None),
|
|
||||||
qweb_node=getattr(exception, 'qweb_node', None),
|
|
||||||
qweb_eval=getattr(exception, 'qweb_eval', None),
|
|
||||||
)
|
|
||||||
if code == 500:
|
if code == 500:
|
||||||
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
|
logger.error("500 Internal Server Error:\n\n%s", values['traceback'])
|
||||||
if values['qweb_template']:
|
if values.get('qweb_exception'):
|
||||||
view = request.registry.get("ir.ui.view")
|
view = request.registry.get("ir.ui.view")
|
||||||
views = view._views_get(request.cr, request.uid, values['qweb_template'], request.context)
|
views = view._views_get(request.cr, request.uid, values['qweb_exception'].template, request.context)
|
||||||
to_reset = [view for view in views if view.model_data_id.noupdate == True]
|
to_reset = [v for v in views if v.model_data_id.noupdate is True]
|
||||||
values['views'] = to_reset
|
values['views'] = to_reset
|
||||||
elif code == 403:
|
elif code == 403:
|
||||||
logger.warn("403 Forbidden:\n\n%s", values['traceback'])
|
logger.warn("403 Forbidden:\n\n%s", values['traceback'])
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import copy
|
import copy
|
||||||
from urlparse import urlparse
|
|
||||||
|
|
||||||
from lxml import etree, html
|
from lxml import etree, html
|
||||||
|
|
||||||
from openerp.osv import osv, fields
|
from openerp.osv import osv, fields
|
||||||
from openerp.addons.base import ir
|
|
||||||
|
|
||||||
class view(osv.osv):
|
class view(osv.osv):
|
||||||
_inherit = "ir.ui.view"
|
_inherit = "ir.ui.view"
|
||||||
|
@ -24,9 +22,9 @@ class view(osv.osv):
|
||||||
# Returns all views (called and inherited) related to a view
|
# Returns all views (called and inherited) related to a view
|
||||||
# Used by translation mechanism, SEO and optional templates
|
# Used by translation mechanism, SEO and optional templates
|
||||||
def _views_get(self, cr, uid, view, options=True, context=None, root=True, stack_result=None):
|
def _views_get(self, cr, uid, view, options=True, context=None, root=True, stack_result=None):
|
||||||
if not context:
|
if not context:
|
||||||
context = {}
|
context = {}
|
||||||
if not stack_result:
|
if not stack_result:
|
||||||
stack_result = []
|
stack_result = []
|
||||||
|
|
||||||
def view_obj(view):
|
def view_obj(view):
|
||||||
|
@ -38,7 +36,11 @@ class view(osv.osv):
|
||||||
view_obj = self.pool.get("ir.ui.view")
|
view_obj = self.pool.get("ir.ui.view")
|
||||||
view = view_obj.browse(cr, uid, view, context=context)
|
view = view_obj.browse(cr, uid, view, context=context)
|
||||||
return view
|
return view
|
||||||
view = view_obj(view)
|
try:
|
||||||
|
view = view_obj(view)
|
||||||
|
except ValueError:
|
||||||
|
# Shall we log that ?
|
||||||
|
return []
|
||||||
|
|
||||||
while root and view.inherit_id:
|
while root and view.inherit_id:
|
||||||
view = view.inherit_id
|
view = view.inherit_id
|
||||||
|
@ -53,7 +55,10 @@ class view(osv.osv):
|
||||||
result.append(r)
|
result.append(r)
|
||||||
node = etree.fromstring(view.arch)
|
node = etree.fromstring(view.arch)
|
||||||
for child in node.xpath("//t[@t-call]"):
|
for child in node.xpath("//t[@t-call]"):
|
||||||
call_view = view_obj(child.get('t-call'))
|
try:
|
||||||
|
call_view = view_obj(child.get('t-call'))
|
||||||
|
except ValueError:
|
||||||
|
continue
|
||||||
if call_view not in result:
|
if call_view not in result:
|
||||||
result += self._views_get(cr, uid, call_view, options=options, context=context, stack_result=result)
|
result += self._views_get(cr, uid, call_view, options=options, context=context, stack_result=result)
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -455,7 +455,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel panel-default" t-if="qweb_template">
|
<div class="panel panel-default" t-if="qweb_exception">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h4 class="panel-title">
|
<h4 class="panel-title">
|
||||||
<a data-toggle="collapse" data-parent="#adebug_infos" href="#error_qweb">
|
<a data-toggle="collapse" data-parent="#adebug_infos" href="#error_qweb">
|
||||||
|
@ -466,11 +466,11 @@
|
||||||
<div id="error_qweb" class="panel-collapse collapse">
|
<div id="error_qweb" class="panel-collapse collapse">
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<p>
|
<p>
|
||||||
The error occured while rendering the template <code t-esc="qweb_template"/>
|
The error occured while rendering the template <code t-esc="qweb_exception.template"/>
|
||||||
<t t-if="qweb_eval">and evaluating the following expression: <code t-esc="qweb_eval"/></t>
|
<t t-if="qweb_exception.expression">and evaluating the following expression: <code t-esc="qweb_exception.expression"/></t>
|
||||||
</p>
|
</p>
|
||||||
<t t-if="qweb_node">
|
<t t-if="qweb_exception.node">
|
||||||
<pre id="exception_node" t-esc="qweb_node.toxml()"/>
|
<pre id="exception_node" t-esc="qweb_exception.node.toxml()"/>
|
||||||
</t>
|
</t>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -567,9 +567,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container" t-if="views">
|
<div class="container" t-if="views">
|
||||||
<div class="alert alert-danger" t-if="qweb_template and editable">
|
<div class="alert alert-danger" t-if="qweb_exception and editable">
|
||||||
<h4>Template fallback</h4>
|
<h4>Template fallback</h4>
|
||||||
<p>An error occured while rendering the template <code t-esc="qweb_template"/>.</p>
|
<p>An error occured while rendering the template <code t-esc="qweb_exception.template"/>.</p>
|
||||||
<p>If this error is caused by a change of yours in the templates, you have the possibility to reset one or more templates to their <strong>factory settings</strong>.</p>
|
<p>If this error is caused by a change of yours in the templates, you have the possibility to reset one or more templates to their <strong>factory settings</strong>.</p>
|
||||||
<form action="/website/reset_templates" method="post">
|
<form action="/website/reset_templates" method="post">
|
||||||
<ul class="oe_template_fallback">
|
<ul class="oe_template_fallback">
|
||||||
|
|
Loading…
Reference in New Issue