diff options
| author | Olivier Dony <odo@openerp.com> | 2015-09-11 11:51:28 +0200 |
|---|---|---|
| committer | Olivier Dony <odo@openerp.com> | 2015-09-11 14:15:57 +0200 |
| commit | abde3e0e5b4ea148889d4e6adf953f64ceb83928 (patch) | |
| tree | 3fcef1deb843a21b6d30be0e54a93c54ed1f01c5 /openerp/exceptions.py | |
| parent | b9420fdea8830f41358074ec5200849b29418db5 (diff) | |
[IMP] http: LazyResponse rendering w/ concurrent access protection
QWeb's LazyResponse mechanism allows controllers to be inherited
and to alter the rendering context (qwebcontext) *after* calling
super().
However it caused the final rendering to occur outside the protection
of the @service.model.check decorator that handles concurrent access
errors. In rare cases the lazy rendering can be interrupted by
a concurrent access error, for example when bootstrapping the
the cache of asset bundles (as it INSERTs a bunch of attachments).
By forcing the flatten()ing of the lazy response earlier, right
after calling the route's endpoint(), it occurs within the
protection of the @service.model.check, and benefits from the
automatic retry.
flatten() was modified to avoid rendering twice the template
The flatten() in get_response() is still necessary for addons
code that directly calls get_response().
Moved QWebException into openerp.exceptions next to the other
exceptions classes - since it now has more global semantics.
~
The whole request dispatching code could really do with a
complete redesign/simplification.
Diffstat (limited to 'openerp/exceptions.py')
| -rw-r--r-- | openerp/exceptions.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/openerp/exceptions.py b/openerp/exceptions.py index 209f2a4cff2..8d0bb779d3e 100644 --- a/openerp/exceptions.py +++ b/openerp/exceptions.py @@ -10,8 +10,9 @@ treated as a 'Server error'. If you consider introducing new exceptions, check out the test_exceptions addon. """ -from inspect import currentframe import logging +from inspect import currentframe +from lxml import etree from tools.func import frame_codeinfo _logger = logging.getLogger(__name__) @@ -90,3 +91,13 @@ class DeferredException(Exception): def __init__(self, msg, tb): self.message = msg self.traceback = tb + +class QWebException(Exception): + def __init__(self, message, **kw): + super(QWebException, self).__init__(message) + self.qweb = dict(kw) + + def pretty_xml(self): + if 'node' not in self.qweb: + return '' + return etree.tostring(self.qweb['node'], pretty_print=True) |
