Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
ab6b6941
Commit
ab6b6941
authored
Jul 10, 2012
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- fixed TypeError handling in unrestrictedTraverse
parent
6d7f64a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
1 deletion
+18
-1
doc/CHANGES.rst
doc/CHANGES.rst
+2
-0
src/OFS/Traversable.py
src/OFS/Traversable.py
+2
-1
src/OFS/tests/testTraverse.py
src/OFS/tests/testTraverse.py
+14
-0
No files found.
doc/CHANGES.rst
View file @
ab6b6941
...
...
@@ -8,6 +8,8 @@ http://docs.zope.org/zope2/releases/.
2.13.16 (unreleased)
--------------------
- OFS: Fixed TypeError handling in unrestrictedTraverse.
- Updated distributions:
- AccessControl = 2.13.8
...
...
src/OFS/Traversable.py
View file @
ab6b6941
...
...
@@ -260,9 +260,10 @@ class Traversable:
if
isinstance
(
next
,
NullResource
):
resource
=
next
raise
KeyError
(
name
)
except
AttributeError
:
except
(
AttributeError
,
TypeError
)
:
# Raise NotFound for easier debugging
# instead of AttributeError: __getitem__
# or TypeError: not subscriptable
raise
NotFound
(
name
)
if
restricted
and
not
validate
(
obj
,
obj
,
None
,
next
):
...
...
src/OFS/tests/testTraverse.py
View file @
ab6b6941
...
...
@@ -402,6 +402,20 @@ class TestTraverse( unittest.TestCase ):
self
.
assertEqual
(
self
.
root
.
folder1
.
restrictedTraverse
(
'stuff'
,
42
),
42
)
def
testNotFoundIsRaised
(
self
):
from
OFS.SimpleItem
import
SimpleItem
from
zExceptions
import
NotFound
from
operator
import
getitem
self
.
folder1
.
_setObject
(
'foo'
,
SimpleItem
(
'foo'
))
self
.
assertRaises
(
AttributeError
,
getitem
,
self
.
folder1
.
foo
,
'doesntexist'
)
self
.
assertRaises
(
NotFound
,
self
.
folder1
.
unrestrictedTraverse
,
'foo/doesntexist'
)
self
.
assertRaises
(
TypeError
,
getitem
,
self
.
folder1
.
foo
.
isPrincipiaFolderish
,
'doesntexist'
)
self
.
assertRaises
(
NotFound
,
self
.
folder1
.
unrestrictedTraverse
,
'foo/isPrincipiaFolderish/doesntexist'
)
def
testDefaultValueWhenNotFound
(
self
):
# Test that traversing to a non-existent object returns
# the default when provided
...
...
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