Skip to content

Commit

Permalink
Add a helper function replacement for IStorage.load
Browse files Browse the repository at this point in the history
Because the error semantics of load and loadBefore differ enough that
changing calls isn't trivial.  Plus the helper serves as a handy
transitional load implementation.
  • Loading branch information
Jim Fulton committed Jun 16, 2016
1 parent 62c3e35 commit ff00117
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/ZODB/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
from ZODB._compat import BytesIO
from ZODB._compat import ascii_bytes


__all__ = ['z64',
'p64',
'u64',
Expand Down Expand Up @@ -375,3 +374,14 @@ def notify_all(self):
else:

from threading import Condition, Lock, RLock


import ZODB.POSException

def load_current(storage, oid, version=''):
assert not version
r = storage.loadBefore(oid, maxtid)
if r is None:
raise ZODB.POSException.POSKeyError(oid)
assert r[2] is None
return r[:2]

0 comments on commit ff00117

Please sign in to comment.