Commit af5253bd authored by Vincent Pelletier's avatar Vincent Pelletier

Implement getTID and checkCurrentSerialInTransaction.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2493 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent f6232c8c
...@@ -194,3 +194,9 @@ class Storage(BaseStorage.BaseStorage, ...@@ -194,3 +194,9 @@ class Storage(BaseStorage.BaseStorage,
def close(self): def close(self):
self.app.close() self.app.close()
def getTID(self, oid):
return self.app.getLastTID(oid)
def checkCurrentSerialInTransaction(self, oid, serial, transaction):
self.app.checkCurrentSerialInTransaction(oid, serial, transaction)
...@@ -24,6 +24,7 @@ import time ...@@ -24,6 +24,7 @@ import time
import os import os
from ZODB.POSException import UndoError, StorageTransactionError, ConflictError from ZODB.POSException import UndoError, StorageTransactionError, ConflictError
from ZODB.POSException import ReadConflictError
from ZODB.ConflictResolution import ResolvedSerial from ZODB.ConflictResolution import ResolvedSerial
from persistent.TimeStamp import TimeStamp from persistent.TimeStamp import TimeStamp
...@@ -1260,3 +1261,13 @@ class Application(object): ...@@ -1260,3 +1261,13 @@ class Application(object):
raise NEOStorageError('Invalid pack time') raise NEOStorageError('Invalid pack time')
self._askPrimary(Packets.AskPack(tid)) self._askPrimary(Packets.AskPack(tid))
def getLastTID(self, oid):
return self._load(oid)[1]
def checkCurrentSerialInTransaction(self, oid, serial, transaction):
if transaction is not self.local_var.txn:
raise StorageTransactionError(self, transaction)
committed_tid = self.getLastTID(oid)
if committed_tid != serial:
raise ReadConflictError(oid=oid, serials=(committed_tid, serial))
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