Skip to content

Commit

Permalink
HistoricalStorageAdapter forwards release() to its instance
Browse files Browse the repository at this point in the history
Fixes #78.

Also adjust the base wrapper's __getattr__ to be faster (500 vs 711ns
in a benchmark of the common case) and behave the same on Python 2 vs
Python 3 with regards to exceptions, should a method be implemented as
an descriptor. In practice this probably makes no difference
whatsoever, it's just the same pattern used for forwarding
release.
  • Loading branch information
jamadden committed Jul 24, 2017
1 parent 5056d49 commit 4051c82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Expand Up @@ -9,6 +9,8 @@

- Drop support for Python 3.3.

- The ``HistoricalStorageAdapter`` forwards the ``release`` method to
its base instance. See `issue 78 <https://github.com/zopefoundation/ZODB/issues/788>`_.

5.2.4 (2017-05-17)
==================
Expand Down
12 changes: 10 additions & 2 deletions src/ZODB/mvccadapter.py
Expand Up @@ -27,8 +27,11 @@ def __init__(self, storage):

def __getattr__(self, name):
if name in self._copy_methods:
if hasattr(self._storage, name):
try:
m = getattr(self._storage, name)
except AttributeError:
pass
else:
setattr(self, name, m)
return m

Expand Down Expand Up @@ -204,7 +207,12 @@ def supportsUndo(self):
return False

def release(self):
pass
try:
release = self._storage.release
except AttributeError:
pass
else:
release()

close = release

Expand Down

0 comments on commit 4051c82

Please sign in to comment.