[IMP] make TestCursor more robust, and remove some tests on tools.config['test_enable']
bzr revid: rco@openerp.com-20140409103337-r0a1nx9h8nfg3cn3
This commit is contained in:
parent
e5e00e4c0a
commit
fd8fd0906f
|
@ -394,8 +394,7 @@ class res_users(osv.osv):
|
|||
# (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:
|
||||
|
|
|
@ -279,7 +279,7 @@ class WebRequest(object):
|
|||
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)
|
||||
|
||||
|
|
|
@ -391,7 +391,6 @@ class TestCursor(Cursor):
|
|||
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()
|
||||
|
@ -401,18 +400,16 @@ class TestCursor(Cursor):
|
|||
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue