Commit 11473bff authored by Julien Muchembled's avatar Julien Muchembled

client: make Storage.history() compatible with recent ZODB API

In particular, this fixes history tab on recent Zope.
parent 7d6b9c87
...@@ -35,6 +35,18 @@ def check_read_only(func): ...@@ -35,6 +35,18 @@ def check_read_only(func):
return func(self, *args, **kw) return func(self, *args, **kw)
return wraps(func)(wrapped) return wraps(func)(wrapped)
def old_history_api(func):
try:
if ZODB.interfaces.IStorage['history'].positional[1] != 'version':
return func # ZODB >= 3.9
except KeyError: # ZODB < 3.8
pass
def history(self, oid, version=None, *args, **kw):
if version is None:
return func(self, oid, *args, **kw)
raise ValueError('Versions are not supported')
return wraps(func)(history)
class Storage(BaseStorage.BaseStorage, class Storage(BaseStorage.BaseStorage,
ConflictResolution.ConflictResolvingStorage): ConflictResolution.ConflictResolvingStorage):
"""Wrapper class for neoclient.""" """Wrapper class for neoclient."""
...@@ -215,9 +227,10 @@ class Storage(BaseStorage.BaseStorage, ...@@ -215,9 +227,10 @@ class Storage(BaseStorage.BaseStorage,
def registerDB(self, db, limit=None): def registerDB(self, db, limit=None):
self.app.registerDB(db, limit) self.app.registerDB(db, limit)
def history(self, oid, version=None, size=1, filter=None): @old_history_api
def history(self, *args, **kw):
try: try:
return self.app.history(oid, version, size, filter) return self.app.history(*args, **kw)
except NEOStorageNotFoundError: except NEOStorageNotFoundError:
raise KeyError raise KeyError
......
...@@ -981,7 +981,7 @@ class Application(object): ...@@ -981,7 +981,7 @@ class Application(object):
append(txn_info) append(txn_info)
return (tid, txn_list) return (tid, txn_list)
def history(self, oid, version=None, size=1, filter=None): def history(self, oid, size=1, filter=None):
queue = self._getThreadQueue() queue = self._getThreadQueue()
# Get history informations for object first # Get history informations for object first
packet = Packets.AskObjectHistory(oid, 0, size) packet = Packets.AskObjectHistory(oid, 0, size)
......
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