Commit deb6272a authored by Jim Fulton's avatar Jim Fulton

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.
parent cf938cee
......@@ -10,7 +10,7 @@ New Features
- 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.
......
......@@ -896,21 +896,20 @@ class DB(object):
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 @@ class DB(object):
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)
......
......@@ -420,7 +420,7 @@ class ZODBTests(ZODB.tests.util.TestCase):
# 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')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment