diff --git a/src/ZODB/interfaces.py b/src/ZODB/interfaces.py index cd49c71ba..c17ff7d30 100644 --- a/src/ZODB/interfaces.py +++ b/src/ZODB/interfaces.py @@ -722,12 +722,8 @@ def tpc_finish(transaction, func = lambda tid: None): called while the storage transaction lock is held. It takes the new transaction id generated by the transaction. - The return value must be the committed tid. It is used to set the - serial for objects whose ids were passed to previous store calls - in the same transaction. - - For compatibility, the return value can also be None, in which case - store/tpc_vote must return the serial of stored objects. + The return value may be None or the transaction id of the + committed transaction, as described in IMultiCommitStorage. """ def tpc_vote(transaction): @@ -743,20 +739,53 @@ def tpc_vote(transaction): without an error, then there must not be an error if tpc_finish or tpc_abort is called subsequently. - The return value can be either None or a sequence of oids for which - a conflict was resolved. - - For compatibility, the return value can also be a sequence of object-id + The return value can be None or a sequence of object-id and serial pairs giving new serials for objects whose ids were passed to previous store calls in the same transaction. The serial can be the special value ZODB.ConflictResolution.ResolvedSerial to indicate that a conflict occurred and that the object should be invalidated. + The return value can also be a sequence of object ids, as + described in IMultiCommitStorage.tpc_vote. + After the tpc_vote call, all solved conflicts must have been notified, either from tpc_vote or store for objects passed to store. """ + +class IMultiCommitStorage(IStorage): + """A multi-commit storage can commit multiple transactions at once. + + It's likely that future versions of ZODB will require all storages + to provide this interface. + """ + + def store(oid, serial, data, version, transaction): + """Store data for the object id, oid. + + See IStorage.store. For objects implementing this interface, + the return value is always None. + """ + + def tpc_finish(transaction, func = lambda tid: None): + """Finish the transaction, making any transaction changes permanent. + + See IStorage.store. For objects implementing this interface, + the return value must be the committed tid. It is used to set the + serial for objects whose ids were passed to previous store calls + in the same transaction. + """ + + def tpc_vote(transaction): + """Provide a storage with an opportunity to veto a transaction + + See IStorage.store. For objects implementing this interface, + the return value can be either None or a sequence of oids for which + a conflict was resolved. + """ + + class IStorageRestoreable(IStorage): """Copying Transactions @@ -893,8 +922,8 @@ def undo(transaction_id, transaction): This method must only be called in the first phase of two-phase commit (after tpc_begin but before tpc_vote). It returns a serial (transaction id) and a sequence of object ids - for objects affected by the transaction. - + for objects affected by the transaction. The serial is ignored + and may be None. """ # Used by DB (Actually, by TransactionalUndo)