Commit 5cc223ea authored by Hanno Schlichting's avatar Hanno Schlichting

Add two fixes for ZODB, not yet fully compatible.

parent d0c33df1
...@@ -25,7 +25,6 @@ import time ...@@ -25,7 +25,6 @@ import time
from ZODB import POSException from ZODB import POSException
from ZODB.BaseStorage import BaseStorage from ZODB.BaseStorage import BaseStorage
from ZODB.ConflictResolution import ConflictResolvingStorage from ZODB.ConflictResolution import ConflictResolvingStorage
from ZODB.ConflictResolution import ResolvedSerial
from ZODB.serialize import referencesf from ZODB.serialize import referencesf
from ZODB.utils import z64 from ZODB.utils import z64
...@@ -219,9 +218,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage): ...@@ -219,9 +218,7 @@ class TemporaryStorage(BaseStorage, ConflictResolvingStorage):
data = newdata data = newdata
else: else:
oserial = serial oserial = serial
newserial = self._tid
self._tmp.append((oid, data)) self._tmp.append((oid, data))
return serial == oserial and newserial or ResolvedSerial
def _finish(self, tid, u, d, e): def _finish(self, tid, u, d, e):
zeros = {} zeros = {}
......
...@@ -21,6 +21,51 @@ from ZODB.tests import ConflictResolution ...@@ -21,6 +21,51 @@ from ZODB.tests import ConflictResolution
from ZODB.tests import MTStorage from ZODB.tests import MTStorage
def handle_all_serials(oid, *args):
"""Return dict of oid to serialno from store() and tpc_vote().
Raises an exception if one of the calls raised an exception.
The storage interface got complicated when ZEO was introduced.
Any individual store() call can return None or a sequence of
2-tuples where the 2-tuple is either oid, serialno or an
exception to be raised by the client.
The original interface just returned the serialno for the
object.
The updated multi-commit API returns nothing from store(), and
returns a sequence of resolved oids from tpc_vote.
NOTE: This function is removed entirely in ZODB 5.
"""
d = {}
for arg in args:
if isinstance(arg, bytes):
d[oid] = arg
elif arg:
for t in arg:
if isinstance(t, bytes):
# New protocol. The caller will use the tid
# returned from tpc_finish if we return a dict
# missing the oid.
pass
else:
oid, serial = t
if not isinstance(serial, bytes):
raise serial # error from ZEO server
d[oid] = serial
return d
def handle_serials(oid, *args):
"""Return the serialno for oid based on multiple return values.
A helper for function _handle_all_serials().
"""
return handle_all_serials(oid, *args).get(oid)
class ZODBProtocolTests(StorageTestBase.StorageTestBase, class ZODBProtocolTests(StorageTestBase.StorageTestBase,
BasicStorage.BasicStorage, BasicStorage.BasicStorage,
Synchronization.SynchronizedStorage, Synchronization.SynchronizedStorage,
...@@ -87,7 +132,7 @@ class TemporaryStorageTests(unittest.TestCase): ...@@ -87,7 +132,7 @@ class TemporaryStorageTests(unittest.TestCase):
r1 = storage.store(oid, revid, data, '', t) r1 = storage.store(oid, revid, data, '', t)
# Finish the transaction # Finish the transaction
r2 = storage.tpc_vote(t) r2 = storage.tpc_vote(t)
revid = StorageTestBase.handle_serials(oid, r1, r2) revid = handle_serials(oid, r1, r2)
storage.tpc_finish(t) storage.tpc_finish(t)
except: except:
storage.tpc_abort(t) storage.tpc_abort(t)
......
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