[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
This commit is contained in:
Christophe Simonis 2014-03-11 10:55:50 +01:00
parent f8bad6f814
commit e634545617
1 changed files with 8 additions and 9 deletions

View File

@ -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):