hooks/integrity.py
changeset 4517 0f3c10fc42b2
parent 4498 ee6362b4618d
child 4530 a3c1549a68c6
--- a/hooks/integrity.py	Tue Feb 09 11:22:40 2010 +0100
+++ b/hooks/integrity.py	Tue Feb 09 12:41:44 2010 +0100
@@ -27,6 +27,7 @@
 _UNIQUE_CONSTRAINTS_LOCK = Lock()
 _UNIQUE_CONSTRAINTS_HOLDER = None
 
+
 def _acquire_unique_cstr_lock(session):
     """acquire the _UNIQUE_CONSTRAINTS_LOCK for the session.
 
@@ -34,19 +35,17 @@
     RQLUniqueConstraint in two different transactions, as explained in
     http://intranet.logilab.fr/jpl/ticket/36564
     """
-    global _UNIQUE_CONSTRAINTS_HOLDER
     asession = session.actual_session()
-    if _UNIQUE_CONSTRAINTS_HOLDER is asession:
+    if 'uniquecstrholder' in asession.transaction_data:
         return
     _UNIQUE_CONSTRAINTS_LOCK.acquire()
-    _UNIQUE_CONSTRAINTS_HOLDER = asession
+    asession.transaction_data['uniquecstrholder'] = True
     # register operation responsible to release the lock on commit/rollback
-    _ReleaseUniqueConstraintsOperation(asession)
+    _ReleaseUniqueConstraintsHook(asession)
 
 def _release_unique_cstr_lock(session):
-    global _UNIQUE_CONSTRAINTS_HOLDER
-    if _UNIQUE_CONSTRAINTS_HOLDER is session:
-        _UNIQUE_CONSTRAINTS_HOLDER = None
+    if 'uniquecstrholder' in session.transaction_data:
+        del session.transaction_data['uniquecstrholder']
         _UNIQUE_CONSTRAINTS_LOCK.release()
 
 class _ReleaseUniqueConstraintsOperation(hook.Operation):