[ADD] ability to trigger retrying rendering with an updated rendering context
This commit is contained in:
parent
381507e6eb
commit
e555855f07
|
@ -1037,6 +1037,15 @@ mimetypes.add_type('application/font-woff', '.woff')
|
||||||
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
|
mimetypes.add_type('application/vnd.ms-fontobject', '.eot')
|
||||||
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
mimetypes.add_type('application/x-font-ttf', '.ttf')
|
||||||
|
|
||||||
|
class Retry(RuntimeError):
|
||||||
|
""" Exception raised during QWeb rendering to signal that the rendering
|
||||||
|
should be retried with the provided ``render_updates`` dict merged into
|
||||||
|
the previous rendering context
|
||||||
|
"""
|
||||||
|
def __init__(self, name, render_updates=None):
|
||||||
|
super(Retry, self).__init__(name)
|
||||||
|
self.updates = render_updates or {}
|
||||||
|
|
||||||
class Response(werkzeug.wrappers.Response):
|
class Response(werkzeug.wrappers.Response):
|
||||||
""" Response object passed through controller route chain.
|
""" Response object passed through controller route chain.
|
||||||
|
|
||||||
|
@ -1077,7 +1086,13 @@ class Response(werkzeug.wrappers.Response):
|
||||||
def render(self):
|
def render(self):
|
||||||
view_obj = request.registry["ir.ui.view"]
|
view_obj = request.registry["ir.ui.view"]
|
||||||
uid = self.uid or request.uid or openerp.SUPERUSER_ID
|
uid = self.uid or request.uid or openerp.SUPERUSER_ID
|
||||||
return view_obj.render(request.cr, uid, self.template, self.qcontext, context=request.context)
|
while True:
|
||||||
|
try:
|
||||||
|
return view_obj.render(
|
||||||
|
request.cr, uid, self.template, self.qcontext,
|
||||||
|
context=request.context)
|
||||||
|
except Retry, e:
|
||||||
|
self.qcontext.update(e.updates)
|
||||||
|
|
||||||
def flatten(self):
|
def flatten(self):
|
||||||
self.response.append(self.render())
|
self.response.append(self.render())
|
||||||
|
|
Loading…
Reference in New Issue