Commit 4d0512f1 authored by Julien Muchembled's avatar Julien Muchembled

Various fixes suggested in review

parent 7e1db13f
......@@ -73,6 +73,7 @@ class DemoStorage(ConflictResolvingStorage):
self._issued_oids = set()
self._stored_oids = set()
self._resolved = []
self._commit_lock = ZODB.utils.Lock()
self._transaction = None
......@@ -116,7 +117,7 @@ class DemoStorage(ConflictResolvingStorage):
for meth in (
'_lock',
'getSize', 'isReadOnly',
'sortKey', 'tpc_transaction', 'tpc_vote',
'sortKey', 'tpc_transaction',
):
setattr(self, meth, getattr(changes, meth))
......@@ -308,7 +309,8 @@ class DemoStorage(ConflictResolvingStorage):
if old != serial:
rdata = self.tryToResolveConflict(oid, old, serial, data)
self.changes.store(oid, old, rdata, '', transaction, True)
self.changes.store(oid, old, rdata, '', transaction)
self._resolved.append(oid)
else:
self.changes.store(oid, serial, data, '', transaction)
......@@ -364,6 +366,13 @@ class DemoStorage(ConflictResolvingStorage):
self.changes.tpc_begin(transaction, *a, **k)
self._transaction = transaction
self._stored_oids = set()
del self._resolved[:]
def tpc_vote(self, *a, **k):
if self.changes.tpc_vote(*a, **k):
raise ZODB.POSException.StorageTransactionError(
"Unexpected resolved conflicts")
return self._resolved
def tpc_finish(self, transaction, func = lambda tid: None):
with self._lock:
......
......@@ -520,6 +520,7 @@ class FileStorage(
if oldserial != committed_tid:
data = self.tryToResolveConflict(oid, committed_tid,
oldserial, data)
self._resolved.append(oid)
pos = self._pos
here = pos + self._tfile.tell() + self._thl
......@@ -534,9 +535,6 @@ class FileStorage(
raise FileStorageQuotaError(
"The storage quota has been exceeded.")
if old and oldserial != committed_tid:
self._resolved.append(oid)
def deleteObject(self, oid, oldserial, transaction):
if self._is_read_only:
raise ReadOnlyError()
......
......@@ -43,7 +43,6 @@ class MappingStorage(object):
self._commit_lock = ZODB.utils.Lock()
self._opened = True
self._transaction = None
self._resolved = []
self._oid = 0
######################################################################
......@@ -233,7 +232,7 @@ class MappingStorage(object):
# ZODB.interfaces.IStorage
@ZODB.utils.locked(opened)
def store(self, oid, serial, data, version, transaction, resolved=False):
def store(self, oid, serial, data, version, transaction):
assert not version, "Versions are not supported"
if transaction is not self._transaction:
raise ZODB.POSException.StorageTransactionError(self, transaction)
......@@ -247,8 +246,6 @@ class MappingStorage(object):
oid=oid, serials=(old_tid, serial), data=data)
self._tdata[oid] = data
if resolved:
self._resolved.append(oid)
checkCurrentSerialInTransaction = (
ZODB.BaseStorage.checkCurrentSerialInTransaction)
......@@ -284,7 +281,6 @@ class MappingStorage(object):
old_tid = None
tid = ZODB.utils.newTid(old_tid)
self._tid = tid
del self._resolved[:]
# ZODB.interfaces.IStorage
@ZODB.utils.locked(opened)
......@@ -321,7 +317,6 @@ class MappingStorage(object):
if transaction is not self._transaction:
raise ZODB.POSException.StorageTransactionError(
"tpc_vote called with wrong transaction")
return self._resolved
class TransactionRecord:
......
......@@ -390,8 +390,6 @@ stored are discarded.
... '', t)
>>> bool(blob_storage.tpc_vote(t))
False
>>> oldserial < blob_storage._tid
True
>>> blob_storage.tpc_abort(t)
Now, the serial for the existing blob should be the same:
......
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