# (In this way, there is no opportunity to have two transactions
# interleaving their cr.execute()..cr.commit() calls and have one
# of them rolled back due to a concurrent access.)
- if not openerp.tools.config['test_enable']:
- cr.autocommit(True)
+ cr.autocommit(True)
# check if user exists
res = self.search(cr, SUPERUSER_ID, [('login','=',login)])
if res:
def checked_call(___dbname, *a, **kw):
# 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 and not openerp.tools.config['test_enable']:
+ if self._cr:
self._cr.rollback()
return self.endpoint(*a, **kw)
super(TestCursor, self).__init__(*args, **kwargs)
super(TestCursor, self).execute("SAVEPOINT test_cursor")
self._lock = threading.RLock()
- self._auto_commit = False
def acquire(self):
self._lock.acquire()
def execute(self, *args, **kwargs):
super(TestCursor, self).execute(*args, **kwargs)
- if self._auto_commit:
- self.commit()
def close(self, force=False):
- self.rollback() # for stuff that has not been committed
if force:
super(TestCursor, self).close()
- else:
+ elif not self._closed:
+ self.rollback() # for stuff that has not been committed
self.release()
def autocommit(self, on):
- self._auto_commit = on
+ _logger.debug("TestCursor.autocommit(%r) does nothing", on)
def commit(self):
super(TestCursor, self).execute("RELEASE SAVEPOINT test_cursor")