Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
a3f43529
Commit
a3f43529
authored
Jul 24, 2017
by
Jason Madden
Committed by
GitHub
Jul 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #170 from zopefoundation/issue78
HistoricalStorageAdapter forwards release() to its instance
parents
5056d49e
c2f9eb70
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
71 additions
and
5 deletions
+71
-5
CHANGES.rst
CHANGES.rst
+2
-0
src/ZODB/mvccadapter.py
src/ZODB/mvccadapter.py
+9
-5
src/ZODB/tests/test_mvccadapter.py
src/ZODB/tests/test_mvccadapter.py
+60
-0
No files found.
CHANGES.rst
View file @
a3f43529
...
...
@@ -9,6 +9,8 @@
- Drop support for Python 3.3.
- Ensure that 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)
==================
...
...
src/ZODB/mvccadapter.py
View file @
a3f43529
...
...
@@ -27,10 +27,9 @@ class Base(object):
def
__getattr__
(
self
,
name
):
if
name
in
self
.
_copy_methods
:
if
hasattr
(
self
.
_storage
,
name
):
m
=
getattr
(
self
.
_storage
,
name
)
setattr
(
self
,
name
,
m
)
return
m
m
=
getattr
(
self
.
_storage
,
name
)
setattr
(
self
,
name
,
m
)
return
m
raise
AttributeError
(
name
)
...
...
@@ -204,7 +203,12 @@ class HistoricalStorageAdapter(Base):
return
False
def
release
(
self
):
pass
try
:
release
=
self
.
_storage
.
release
except
AttributeError
:
pass
else
:
release
()
close
=
release
...
...
src/ZODB/tests/test_mvccadapter.py
0 → 100644
View file @
a3f43529
##############################################################################
#
# Copyright (c) 2017 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
unittest
from
ZODB
import
mvccadapter
class
TestBase
(
unittest
.
TestCase
):
def
test_getattr_does_not_hide_exceptions
(
self
):
class
TheException
(
Exception
):
pass
class
RaisesOnAccess
(
object
):
@
property
def
thing
(
self
):
raise
TheException
()
base
=
mvccadapter
.
Base
(
RaisesOnAccess
())
base
.
_copy_methods
=
(
'thing'
,)
with
self
.
assertRaises
(
TheException
):
getattr
(
base
,
'thing'
)
def
test_getattr_raises_if_missing
(
self
):
base
=
mvccadapter
.
Base
(
self
)
base
.
_copy_methods
=
(
'thing'
,)
with
self
.
assertRaises
(
AttributeError
):
getattr
(
base
,
'thing'
)
class
TestHistoricalStorageAdapter
(
unittest
.
TestCase
):
def
test_forwards_release
(
self
):
class
Base
(
object
):
released
=
False
def
release
(
self
):
self
.
released
=
True
base
=
Base
()
adapter
=
mvccadapter
.
HistoricalStorageAdapter
(
base
,
None
)
adapter
.
release
()
self
.
assertTrue
(
base
.
released
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment