Commit 6496e634 authored by Vincent Pelletier's avatar Vincent Pelletier

Answer OidNotFound to AskObjectHistory when object doesn't exist.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2568 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent e0054ef6
......@@ -232,7 +232,10 @@ class Storage(BaseStorage.BaseStorage,
self.app.registerDB(db, limit)
def history(self, oid, version=None, size=1, filter=None):
return self.app.history(oid, version, size, filter)
try:
return self.app.history(oid, version, size, filter)
except NEOStorageNotFoundError:
raise KeyError
def sync(self, force=True):
self._snapshot_tid = None
......
......@@ -1231,12 +1231,6 @@ class Application(object):
if not isinstance(self.local_var.history, tuple):
raise NEOStorageError('history failed')
if self.local_var.history[1] == [] or \
self.local_var.history[1][0][1] == 0:
# KeyError expected if no history was found
# XXX: this may requires an error from the storages
raise KeyError
# Now that we have object informations, get txn informations
history_list = []
for serial, size in self.local_var.history[1]:
......
......@@ -147,8 +147,10 @@ class ClientOperationHandler(BaseClientAndStorageOperationHandler):
app = self.app
history_list = app.dm.getObjectHistory(oid, first, last - first)
if history_list is None:
history_list = []
conn.answer(Packets.AnswerObjectHistory(oid, history_list))
p = Errors.OidNotFound(dump(oid))
else:
p = Packets.AnswerObjectHistory(oid, history_list)
conn.answer(p)
def askCheckCurrentSerial(self, conn, tid, serial, oid):
self._askCheckCurrentSerial(conn, tid, serial, oid, time.time())
......
......@@ -177,7 +177,7 @@ class StorageClientHandlerTests(NeoUnitTestBase):
conn = self._getConnection()
self.app.dm = Mock({'getObjectHistory': None})
self.operation.askObjectHistory(conn, oid1, 1, 2)
self.checkAnswerObjectHistory(conn)
self.checkErrorPacket(conn)
# second case: not empty history
conn = self._getConnection()
serial = self.getNextTID()
......
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