Commit 2c17284f authored by Julien Muchembled's avatar Julien Muchembled

client: remove duplicate 'snapshot_tid' parameter of Application.load

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2712 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent edde1fe3
......@@ -119,16 +119,13 @@ class Storage(BaseStorage.BaseStorage,
self._snapshot_tid = tid
return tid
def _load(self, *args, **kw):
return self.app.load(self._getSnapshotTID(), *args, **kw)
def load(self, oid, version=''):
# XXX: interface definition states that version parameter is
# mandatory, while some ZODB tests do not provide it. For now, make
# it optional.
assert version == '', 'Versions are not supported'
try:
return self._load(oid)[:2]
return self.app.load(oid, None, self._getSnapshotTID())[:2]
except NEOStorageNotFoundError:
raise POSException.POSKeyError(oid)
......@@ -174,13 +171,13 @@ class Storage(BaseStorage.BaseStorage,
# mutliple revisions
def loadSerial(self, oid, serial):
try:
return self._load(oid, serial=serial)[0]
return self.app.load(oid, serial)[0]
except NEOStorageNotFoundError:
raise POSException.POSKeyError(oid)
def loadBefore(self, oid, tid):
try:
return self._load(oid, tid=tid)
return self.app.load(oid, None, tid)
except NEOStorageDoesNotExistError:
raise POSException.POSKeyError(oid)
except NEOStorageNotFoundError:
......@@ -222,7 +219,7 @@ class Storage(BaseStorage.BaseStorage,
def loadEx(self, oid, version):
try:
data, serial, _ = self._load(oid)
data, serial, _ = self.app.load(oid, None, self._getSnapshotTID())
except NEOStorageNotFoundError:
raise POSException.POSKeyError(oid)
return data, serial, ''
......
......@@ -382,19 +382,16 @@ class Application(object):
return int(u64(self.last_oid))
@profiler_decorator
def load(self, snapshot_tid, oid, serial=None, tid=None):
def load(self, oid, tid=None, before_tid=None):
"""
Internal method which manage load, loadSerial and loadBefore.
OID and TID (serial) parameters are expected packed.
snapshot_tid
First TID not visible to current transaction.
Set to None for no limit.
oid
OID of object to get.
serial
If given, the exact serial at which OID is desired.
tid should be None.
tid
If given, the exact serial at which OID is desired.
before_tid should be None.
before_tid
If given, the excluded upper bound serial at which OID is desired.
serial should be None.
......@@ -413,25 +410,19 @@ class Application(object):
object doesn't exist
NEOStorageCreationUndoneError
object existed, but its creation was undone
Note that loadSerial is used during conflict resolution to load
object's current version, which is not visible to us normaly (it was
committed after our snapshot was taken).
"""
# TODO:
# - rename parameters (here and in handlers & packet definitions)
if snapshot_tid is not None:
if serial is None:
if tid is None:
tid = snapshot_tid
else:
tid = min(tid, snapshot_tid)
# XXX: we must not clamp serial with snapshot_tid, as loadSerial is
# used during conflict resolution to load object's current version,
# which is not visible to us normaly (it was committed after our
# snapshot was taken).
# - rename parameters (here? and in handlers & packet definitions)
self._load_lock_acquire()
try:
result = self._loadFromCache(oid, serial, tid)
result = self._loadFromCache(oid, tid, before_tid)
if not result:
result = self._loadFromStorage(oid, serial, tid)
result = self._loadFromStorage(oid, tid, before_tid)
self._cache_lock_acquire()
try:
self._cache.store(oid, *result)
......@@ -869,11 +860,9 @@ class Application(object):
# object. This is an undo conflict, try to resolve it.
try:
# Load the latest version we are supposed to see
data = self.load(snapshot_tid, oid,
serial=current_serial)[0]
data = self.load(oid, current_serial, snapshot_tid)[0]
# Load the version we were undoing to
undo_data = self.load(snapshot_tid, oid,
serial=undo_serial)[0]
undo_data = self.load(oid, undo_serial, snapshot_tid)[0]
except NEOStorageNotFoundError:
raise UndoError('Object not found while resolving undo '
'conflict')
......@@ -1084,7 +1073,7 @@ class Application(object):
self._cache_lock_release()
def getLastTID(self, oid):
return self.load(None, oid)[1]
return self.load(oid)[1]
def checkCurrentSerialInTransaction(self, oid, serial, transaction):
txn_context = self._txn_container.get(transaction)
......
......@@ -63,7 +63,7 @@ class Transaction(BaseStorage.TransactionRecord):
while oid_index < oid_len:
oid = oid_list[oid_index]
try:
data, _, next_tid = app.load(None, oid, serial=self.tid)
data, _, next_tid = app.load(oid, self.tid)
except NEOStorageCreationUndoneError:
data = next_tid = None
except NEOStorageNotFoundError:
......
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