From e634545617a4dfd6fde458f4427d9169f5c4bfe1 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Tue, 11 Mar 2014 10:55:50 +0100 Subject: [PATCH] [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 --- openerp/http.py | 17 ++++++++--------- 1 file 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):