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