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
76fccc3c
Commit
76fccc3c
authored
Aug 01, 2006
by
Alec Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge the fix in r69331 from 2.10 branch (WebDAV/HEAD request acquisition issue)
parent
0a97af04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
4 deletions
+30
-4
lib/python/OFS/Traversable.py
lib/python/OFS/Traversable.py
+14
-2
lib/python/OFS/tests/testTraverse.py
lib/python/OFS/tests/testTraverse.py
+16
-2
No files found.
lib/python/OFS/Traversable.py
View file @
76fccc3c
...
@@ -26,6 +26,7 @@ from Acquisition import Acquired, aq_inner, aq_parent, aq_base
...
@@ -26,6 +26,7 @@ from Acquisition import Acquired, aq_inner, aq_parent, aq_base
from
zExceptions
import
NotFound
from
zExceptions
import
NotFound
from
ZODB.POSException
import
ConflictError
from
ZODB.POSException
import
ConflictError
from
OFS.interfaces
import
ITraversable
from
OFS.interfaces
import
ITraversable
import
webdav
from
zope.interface
import
implements
,
Interface
from
zope.interface
import
implements
,
Interface
from
zope.component
import
queryMultiAdapter
from
zope.component
import
queryMultiAdapter
...
@@ -165,6 +166,7 @@ class Traversable:
...
@@ -165,6 +166,7 @@ class Traversable:
else
:
else
:
obj
=
self
obj
=
self
resource
=
_marker
try
:
try
:
while
path
:
while
path
:
name
=
path_pop
()
name
=
path_pop
()
...
@@ -237,6 +239,13 @@ class Traversable:
...
@@ -237,6 +239,13 @@ class Traversable:
else
:
else
:
try
:
try
:
next
=
obj
[
name
]
next
=
obj
[
name
]
# The item lookup may return a NullResource,
# if this is the case we save it and return it
# if all other lookups fail.
if
isinstance
(
next
,
webdav
.
NullResource
.
NullResource
):
resource
=
next
raise
KeyError
(
name
)
except
AttributeError
:
except
AttributeError
:
# Raise NotFound for easier debugging
# Raise NotFound for easier debugging
# instead of AttributeError: __getitem__
# instead of AttributeError: __getitem__
...
@@ -268,8 +277,11 @@ class Traversable:
...
@@ -268,8 +277,11 @@ class Traversable:
except
AttributeError
:
except
AttributeError
:
raise
e
raise
e
if
next
is
_marker
:
if
next
is
_marker
:
# Nothing found re-raise error
# If we have a NullResource from earlier use it.
raise
e
next
=
resource
if
next
is
_marker
:
# Nothing found re-raise error
raise
e
obj
=
next
obj
=
next
...
...
lib/python/OFS/tests/testTraverse.py
View file @
76fccc3c
...
@@ -592,11 +592,25 @@ def test_view_doesnt_shadow_attribute():
...
@@ -592,11 +592,25 @@ def test_view_doesnt_shadow_attribute():
However, acquired attributes *should* be shadowed. See discussion on
However, acquired attributes *should* be shadowed. See discussion on
http://codespeak.net/pipermail/z3-five/2006q2/001474.html
http://codespeak.net/pipermail/z3-five/2006q2/001474.html
>>> manage_addIndexSimpleContent(self.folder, 'mouse', 'Mouse')
>>> manage_addIndexSimpleContent(self.folder, 'mouse', 'Mouse')
>>> self.folder.ftf.unrestrictedTraverse('mouse')()
>>> self.folder.ftf.unrestrictedTraverse('mouse')()
u'The mouse has been eaten by the eagle'
u'The mouse has been eaten by the eagle'
Head requests have some unusual behavior in Zope 2, in particular, a failed
item lookup on an ObjectManager returns a NullResource, rather
than raising a KeyError. We need to make sure that this doesn't
result in acquired attributes being shadowed by the NullResource,
but that unknown names still give NullResources:
>>> self.app.REQUEST.maybe_webdav_client = True
>>> self.app.REQUEST['REQUEST_METHOD'] = 'HEAD'
>>> self.folder.ftf.unrestrictedTraverse('mouse')()
u'The mouse has been eaten by the eagle'
>>> self.folder.ftf.unrestrictedTraverse('nonsense')
<webdav.NullResource.NullResource object at ...>
Clean up:
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
>>> from zope.app.testing.placelesssetup import tearDown
...
...
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