[z3-five] traversal bug with OFS.Application.Application
Jordan Baker
jbb at contradix.com
Tue Apr 4 20:42:13 CEST 2006
After upgrading to Zope 2.9.2 from 2.9.0 I found that one my applications
wasn't working anymore.
It depended on being able to bind a page template to
OFS.Application.Application and through some examination I found a small bug
in the traversal fallback changes that were made recently.
It basically boils down to OFS.Application.Application's __bobo_traverse__
raises NotFound when there is a valid REQUEST.
I've attached a unit test that demonstrates the problem and also the small
patch which fixes it.
PS. There are two questions I had for more experienced testers on this list:
1. Why does http() return 404 but then actually return the correct content in
the test case I added?
2. Why must I use zope2.View instead of zope2.Public. If I use zope2.Public I
get authentication errors?
--
Jordan Baker (jbb at contradix.com)
===================================================================
Index: browser/tests/test_traversable.py
===================================================================
--- browser/tests/test_traversable.py (revision 66357)
+++ browser/tests/test_traversable.py (working copy)
@@ -258,7 +258,46 @@
>>> tearDown()
"""
+def test_traverse_ofs_application():
+ """
+ Test for Five fallback when traversing OFS.Application.Application.
+ In Zope 2.9.2 OFS.Application.Application.__bobo_traverse__ raises NotFound
when it has a REQUEST and so its impossible to use Five traversal with it.
+ Set up:
+
+
+ >>> from zope.app.testing.placelesssetup import setUp, tearDown
+ >>> setUp()
+
+ >>> configure_zcml = '''
+ ... <configure xmlns="http://namespaces.zope.org/zope"
+ ... xmlns:five="http://namespaces.zope.org/five"
+ ... xmlns:browser="http://namespaces.zope.org/browser">
+ ... <five:traversable class="OFS.Application.Application"/>
+ ... <browser:page for="*" name="hello.html"
template="browser/tests/falcon.pt" permission="zope2.View"/>
+ ... </configure>'''
+
+ >>> import Products.Five
+ >>> from Products.Five import zcml
+ >>> zcml.load_config('configure.zcml', Products.Five)
+ >>> zcml.load_string(configure_zcml)
+
+ >>> print http(r'''
+ ... GET /hello.html HTTP/1.1
+ ...
+ ... ''')
+ HTTP/1.1 404 Not Found
+ Content-Length: 35
+ Content-Type: text/html; charset=iso-8859-15
+ <BLANKLINE>
+ <p>The falcon has taken flight</p>
+ <BLANKLINE>
+
+ Clean up:
+
+ >>> tearDown()
+ """
+
def test_suite():
from Testing.ZopeTestCase import FunctionalDocTestSuite
return FunctionalDocTestSuite()
Index: traversable.py
===================================================================
--- traversable.py (revision 66357)
+++ traversable.py (working copy)
@@ -61,7 +61,7 @@
if hasattr(self, '__fallback_traverse__'):
try:
return self.__fallback_traverse__(REQUEST, name)
- except (AttributeError, KeyError):
+ except (NotFound, AttributeError, KeyError):
pass
else:
try:
More information about the z3-five
mailing list