[Zodb-checkins] SVN: ZODB/trunk/src/ Tweaked the undo api. Now undo multiple transactions with

Jim Fulton jim at zope.com
Fri Jan 8 17:55:02 EST 2010


Log message for revision 107901:
  Tweaked the undo api. Now undo multiple transactions with
  undoMultiple. This gives applications that want to support older
  versions of ZODB a method to test for.
  

Changed:
  U   ZODB/trunk/src/CHANGES.txt
  U   ZODB/trunk/src/ZODB/DB.py
  U   ZODB/trunk/src/ZODB/tests/testZODB.py

-=-
Modified: ZODB/trunk/src/CHANGES.txt
===================================================================
--- ZODB/trunk/src/CHANGES.txt	2010-01-08 22:50:51 UTC (rev 107900)
+++ ZODB/trunk/src/CHANGES.txt	2010-01-08 22:55:02 UTC (rev 107901)
@@ -10,7 +10,7 @@
 
 - The API for undoing multiple transactions has changed.  To undo
   multiple transactions in a single transaction, pass pass a list of
-  transaction identifiers to a database's undo method. Calling a
+  transaction identifiers to a database's undoMultiple method. Calling a
   database's undo method multiple times in the same transaction now
   raises an exception.
 

Modified: ZODB/trunk/src/ZODB/DB.py
===================================================================
--- ZODB/trunk/src/ZODB/DB.py	2010-01-08 22:50:51 UTC (rev 107900)
+++ ZODB/trunk/src/ZODB/DB.py	2010-01-08 22:55:02 UTC (rev 107901)
@@ -896,21 +896,20 @@
         finally:
             self._r()
 
-    def undo(self, ids, txn=None):
-        """Undo a transaction identified by id.
+    def undoMultiple(self, ids, txn=None):
+        """Undo multiple transactions identified by ids.
 
         A transaction can be undone if all of the objects involved in
         the transaction were not modified subsequently, if any
         modifications can be resolved by conflict resolution, or if
         subsequent changes resulted in the same object state.
 
-        The value of id should be generated by calling undoLog()
-        or undoInfo().  The value of id is not the same as a
-        transaction id used by other methods; it is unique to undo().
+        The values in ids should be generated by calling undoLog()
+        or undoInfo().  The value of ids are not the same as a
+        transaction ids used by other methods; they are unique to undo().
 
         :Parameters:
           - `ids`: a sequence of storage-specific transaction identifiers
-                   or a single transaction identifier
           - `txn`: transaction context to use for undo().
             By default, uses the current transaction.
         """
@@ -920,6 +919,25 @@
             ids = [ids]
         txn.join(TransactionalUndo(self, ids))
 
+    def undo(self, id, txn=None):
+        """Undo a transaction identified by id.
+
+        A transaction can be undone if all of the objects involved in
+        the transaction were not modified subsequently, if any
+        modifications can be resolved by conflict resolution, or if
+        subsequent changes resulted in the same object state.
+
+        The value of id should be generated by calling undoLog()
+        or undoInfo().  The value of id is not the same as a
+        transaction id used by other methods; it is unique to undo().
+
+        :Parameters:
+          - `id`: a transaction identifier
+          - `txn`: transaction context to use for undo().
+            By default, uses the current transaction.
+        """
+        self.undoMultiple([id], txn)
+
     def transaction(self):
         return ContextManager(self)
 

Modified: ZODB/trunk/src/ZODB/tests/testZODB.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testZODB.py	2010-01-08 22:50:51 UTC (rev 107900)
+++ ZODB/trunk/src/ZODB/tests/testZODB.py	2010-01-08 22:55:02 UTC (rev 107901)
@@ -420,7 +420,7 @@
             # performed yet.
             transaction.begin()
             log = self._db.undoLog()
-            self._db.undo([log[i]['id'] for i in range(5)])
+            self._db.undoMultiple([log[i]['id'] for i in range(5)])
 
             transaction.get().note('undo states 1 through 5')
 



More information about the Zodb-checkins mailing list