Commit 6f3ac9bf authored by Jeremy Hylton's avatar Jeremy Hylton

Add support for transactionalUndo

parent dc9cae12
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Network ZODB storage client """Network ZODB storage client
""" """
__version__='$Revision: 1.30 $'[11:-2] __version__='$Revision: 1.31 $'[11:-2]
import struct, time, os, socket, string, Sync, zrpc, ClientCache import struct, time, os, socket, string, Sync, zrpc, ClientCache
import tempfile, Invalidator, ExtensionClass, thread import tempfile, Invalidator, ExtensionClass, thread
...@@ -429,6 +429,8 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -429,6 +429,8 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
def supportsUndo(self): return self._info['supportsUndo'] def supportsUndo(self): return self._info['supportsUndo']
def supportsVersions(self): return self._info['supportsVersions'] def supportsVersions(self): return self._info['supportsVersions']
def supportsTransactionalUndo(self):
return self._info['supportsTransactionalUndo']
def tpc_abort(self, transaction): def tpc_abort(self, transaction):
self._lock_acquire() self._lock_acquire()
...@@ -547,6 +549,18 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage): ...@@ -547,6 +549,18 @@ class ClientStorage(ExtensionClass.Base, BaseStorage.BaseStorage):
self._commit_lock_release() self._commit_lock_release()
finally: self._lock_release() finally: self._lock_release()
def transactionalUndo(self, trans_id, trans):
self._lock_acquire()
try:
if trans is not self._transaction:
raise POSException.StorageTransactionError(self, transaction)
oids = self._call('transactionalUndo', trans_id, self._serial)
for oid in oids:
# write invalidation records with no version
self._tfile.write("i%s\000\000" % oid)
return oids
finally: self._lock_release()
def undo(self, transaction_id): def undo(self, transaction_id):
self._lock_acquire() self._lock_acquire()
try: try:
......
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
# #
############################################################################## ##############################################################################
__version__ = "$Revision: 1.25 $"[11:-2] __version__ = "$Revision: 1.26 $"[11:-2]
import asyncore, socket, string, sys, os import asyncore, socket, string, sys, os
from smac import SizedMessageAsyncConnection from smac import SizedMessageAsyncConnection
...@@ -201,6 +201,7 @@ for n in ( ...@@ -201,6 +201,7 @@ for n in (
'modifiedInVersion', 'new_oid', 'new_oids', 'pack', 'store', 'modifiedInVersion', 'new_oid', 'new_oids', 'pack', 'store',
'storea', 'tpc_abort', 'tpc_begin', 'tpc_begin_sync', 'storea', 'tpc_abort', 'tpc_begin', 'tpc_begin_sync',
'tpc_finish', 'undo', 'undoLog', 'undoInfo', 'versionEmpty', 'versions', 'tpc_finish', 'undo', 'undoLog', 'undoInfo', 'versionEmpty', 'versions',
'transactionalUndo',
'vote', 'zeoLoad', 'zeoVerify', 'beginZeoVerify', 'endZeoVerify', 'vote', 'zeoLoad', 'zeoVerify', 'beginZeoVerify', 'endZeoVerify',
): ):
storage_methods[n]=1 storage_methods[n]=1
...@@ -320,6 +321,7 @@ class ZEOConnection(SizedMessageAsyncConnection): ...@@ -320,6 +321,7 @@ class ZEOConnection(SizedMessageAsyncConnection):
'name': storage.getName(), 'name': storage.getName(),
'supportsUndo': storage.supportsUndo(), 'supportsUndo': storage.supportsUndo(),
'supportsVersions': storage.supportsVersions(), 'supportsVersions': storage.supportsVersions(),
'supportsTransactionalUndo': storage.supportsTransactionalUndo(),
} }
def get_size_info(self): def get_size_info(self):
...@@ -452,6 +454,12 @@ class ZEOConnection(SizedMessageAsyncConnection): ...@@ -452,6 +454,12 @@ class ZEOConnection(SizedMessageAsyncConnection):
raise POSException.StorageTransactionError(self, id) raise POSException.StorageTransactionError(self, id)
return self.__storage.tpc_vote(t) return self.__storage.tpc_vote(t)
def transactionalUndo(self, trans_id, id):
t=self._transaction
if t is None or id != t.id:
raise POSException.StorageTransactionError(self, id)
return self.__storage.transactionalUndo(trans_id, self._transaction)
def undo(self, transaction_id): def undo(self, transaction_id):
oids=self.__storage.undo(transaction_id) oids=self.__storage.undo(transaction_id)
if oids: if oids:
......
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