Commit d968a9a8 authored by Kirill Smelkov's avatar Kirill Smelkov

Handle NotImplementedError raised by loadBefore/loadBeforeEx as "interface not provided"

Suggested by @d-maurer: https://github.com/zopefoundation/ZODB/pull/323#discussion_r625573381
parent 805bf36f
......@@ -268,8 +268,15 @@ class BaseStorage(UndoLogCompatible):
raise POSException.Unsupported(
"Retrieval of historical revisions is not supported")
# do not provide loadBeforeEx/loadBefore here in BaseStorage - if child forgets
# to override it - storage will always return "no data" instead of failing.
def loadBefore(self, oid, tid):
"""Return most recent revision of oid before tid committed."""
raise NotImplementedError
def loadBeforeEx(self, oid, before):
"""Return most recent revision of oid as of <before database state.
(see IStorageLoadBeforeEx).
"""
raise NotImplementedError
def copyTransactionsFrom(self, other, verbose=0):
"""Copy transactions from another storage.
......
......@@ -397,7 +397,10 @@ def loadBeforeEx(storage, oid, before):
"""
loadBeforeEx = getattr(storage, 'loadBeforeEx', None)
if loadBeforeEx is not None:
try:
return loadBeforeEx(oid, before)
except NotImplementedError:
pass
# storage does not provide IStorageLoadBeforeEx - warn + fall back to loadBefore
if type(storage) not in _loadBeforeExWarned:
......
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