[Checkins] SVN: z3c.zalchemy/trunk/src/z3c/zalchemy/ fixed a bug in the conflict detection: savepoints where not regarded.

Christian Zagrodnick cz at gocept.com
Tue Nov 13 02:47:47 EST 2007


Log message for revision 81806:
  fixed a bug in the conflict detection: savepoints where not regarded.
  
  

Changed:
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
  U   z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt

-=-
Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2007-11-13 07:12:39 UTC (rev 81805)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/datamanager.py	2007-11-13 07:47:47 UTC (rev 81806)
@@ -213,13 +213,7 @@
         pass
 
     def commit(self, trans):
-        try:
-            self.session.flush()
-        except Exception, e:
-            conflict = z3c.zalchemy.interfaces.IConflictError(e, None)
-            if conflict is None:
-                raise
-            raise conflict
+        self._flush_session()
 
     def tpc_vote(self, trans):
         pass
@@ -236,14 +230,23 @@
         return str(id(self))
 
     def savepoint(self):
-        self.session.flush()
+        self._flush_session()
         return AlchemySavepoint()
 
     def _cleanup(self):
         self.session.clear()
         del ctx.current
 
+    def _flush_session(self):
+        try:
+            self.session.flush()
+        except Exception, e:
+            conflict = z3c.zalchemy.interfaces.IConflictError(e, None)
+            if conflict is None:
+                raise
+            raise conflict
 
+
 class AlchemySavepoint(object):
     """A savepoint for the AlchemyDataManager that only supports optimistic
     savepoints.

Modified: z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt
===================================================================
--- z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt	2007-11-13 07:12:39 UTC (rev 81805)
+++ z3c.zalchemy/trunk/src/z3c/zalchemy/tests/TRANSACTION.txt	2007-11-13 07:47:47 UTC (rev 81806)
@@ -264,8 +264,27 @@
 Traceback (most recent call last):
     ...
 SQLError: (ValueError) No conflict 'UPDATE bla...' (1, 2, 3)
-    
+   
 
+The same happens for savepoints where conflicts also might happen:
+
+>>> MockSession.conflict = 'Conflict'
+>>> dm.savepoint()
+Traceback (most recent call last):
+    ...
+ConflictError: play it again
+
+
+Non-conflict errors are passed as well:
+
+>>> MockSession.conflict = 'Not at all'
+>>> dm.savepoint()
+Traceback (most recent call last):
+    ...
+SQLError: (ValueError) Not at all 'UPDATE bla...' (1, 2, 3)
+
+
+
 Clean up:
 
 >>> gsm.unregisterAdapter(adapt_sqlerror,



More information about the Checkins mailing list