diff options
| author | Christophe Simonis <chs@openerp.com> | 2014-03-11 10:55:50 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2014-03-11 10:55:50 +0100 |
| commit | e634545617a4dfd6fde458f4427d9169f5c4bfe1 (patch) | |
| tree | 1cee0fbe01b994f939ad0113dbec30a60e646e72 | |
| parent | f8bad6f81467658103a8ffc6d3f3eadd42b1f371 (diff) | |
[FIX] http: ensure to clean the request cursor before calling the route function.
The route function can be call more than once in case of database error,
breaking the request cursor. By rollbacking it, we force the creation of a new transaction.
bzr revid: chs@openerp.com-20140311095550-lg3nvvjyojvgp2po
| -rw-r--r-- | openerp/http.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/openerp/http.py b/openerp/http.py index 37017751b95..5b01922bfb5 100644 --- a/openerp/http.py +++ b/openerp/http.py @@ -206,20 +206,19 @@ class WebRequest(object): # Backward for 7.0 if getattr(self.func.method, '_first_arg_is_req', False): args = (request,) + args + # Correct exception handling and concurency retry @service_model.check def checked_call(___dbname, *a, **kw): - return self.func(*a, **kw) - - # FIXME: code and rollback management could be cleaned - try: - if self.db: - return checked_call(self.db, *args, **kwargs) - return self.func(*args, **kwargs) - except Exception: + # The decorator can call us more than once if there is an database error. In this + # case, the request cursor is unusable. Rollback transaction to create a new one. if self._cr: self._cr.rollback() - raise + return self.func(*a, **kw) + + if self.db: + return checked_call(self.db, *args, **kwargs) + return self.func(*args, **kwargs) @property def debug(self): |
