Log message for revision 69331: Fix bug in WebDAV/HEAD requests caused by traversal order change
Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/OFS/Traversable.py U Zope/branches/2.10/lib/python/OFS/tests/testTraverse.py -=- Modified: Zope/branches/2.10/doc/CHANGES.txt =================================================================== --- Zope/branches/2.10/doc/CHANGES.txt 2006-08-01 18:17:53 UTC (rev 69330) +++ Zope/branches/2.10/doc/CHANGES.txt 2006-08-01 19:30:42 UTC (rev 69331) @@ -8,6 +8,9 @@ Bugs Fixed + - Traversal order changes were causing WebDAV requests which used + acquisition to fail. + - Collector #2157: Expose name of broken class in SystemError raised from '__getstate__' of a broken instance. Modified: Zope/branches/2.10/lib/python/OFS/Traversable.py =================================================================== --- Zope/branches/2.10/lib/python/OFS/Traversable.py 2006-08-01 18:17:53 UTC (rev 69330) +++ Zope/branches/2.10/lib/python/OFS/Traversable.py 2006-08-01 19:30:42 UTC (rev 69331) @@ -26,6 +26,7 @@ from zExceptions import NotFound from ZODB.POSException import ConflictError from OFS.interfaces import ITraversable +import webdav from zope.interface import implements, Interface from zope.component import queryMultiAdapter @@ -165,6 +166,7 @@ else: obj = self + resource = _marker try: while path: name = path_pop() @@ -237,6 +239,13 @@ else: try: 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: # Raise NotFound for easier debugging # instead of AttributeError: __getitem__ @@ -268,8 +277,11 @@ except AttributeError: raise e if next is _marker: - # Nothing found re-raise error - raise e + # If we have a NullResource from earlier use it. + next = resource + if next is _marker: + # Nothing found re-raise error + raise e obj = next Modified: Zope/branches/2.10/lib/python/OFS/tests/testTraverse.py =================================================================== --- Zope/branches/2.10/lib/python/OFS/tests/testTraverse.py 2006-08-01 18:17:53 UTC (rev 69330) +++ Zope/branches/2.10/lib/python/OFS/tests/testTraverse.py 2006-08-01 19:30:42 UTC (rev 69331) @@ -592,11 +592,25 @@ However, acquired attributes *should* be shadowed. See discussion on http://codespeak.net/pipermail/z3-five/2006q2/001474.html - + >>> manage_addIndexSimpleContent(self.folder, 'mouse', 'Mouse') >>> self.folder.ftf.unrestrictedTraverse('mouse')() 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: >>> from zope.app.testing.placelesssetup import tearDown _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins