[z3-checkins] r6847 - in z3/Five/branch/dc-traversal-issue: . tests

dreamcatcher at codespeak.net dreamcatcher at codespeak.net
Mon Oct 4 16:44:58 MEST 2004


Author: dreamcatcher
Date: Mon Oct  4 16:44:58 2004
New Revision: 6847

Modified:
   z3/Five/branch/dc-traversal-issue/tests/test_five.py
   z3/Five/branch/dc-traversal-issue/traversable.py
Log:
Raise AttributeError instead. Zope should handle it (after the patch I submit gets in *wink*)

Modified: z3/Five/branch/dc-traversal-issue/tests/test_five.py
==============================================================================
--- z3/Five/branch/dc-traversal-issue/tests/test_five.py	(original)
+++ z3/Five/branch/dc-traversal-issue/tests/test_five.py	Mon Oct  4 16:44:58 2004
@@ -238,8 +238,8 @@
             view = self.folder.unrestrictedTraverse(base % macro)
         self.failUnless(view)
 
-    def test_ignore_new_style_class(self):
-        self.assertRaises(NotFound, self.folder.unrestrictedTraverse,
+    def test_unrestrictedTraverse_non_existing(self):
+        self.assertRaises(AttributeError, self.folder.unrestrictedTraverse,
                           'testoid/@@invalid_page')
 
     def test_get_widgets_for_schema_fields(self):

Modified: z3/Five/branch/dc-traversal-issue/traversable.py
==============================================================================
--- z3/Five/branch/dc-traversal-issue/traversable.py	(original)
+++ z3/Five/branch/dc-traversal-issue/traversable.py	Mon Oct  4 16:44:58 2004
@@ -45,38 +45,9 @@
         This method is called by __bobo_traverse___ when Zope3-style
         ITraverser traversal fails.
 
-        Try to look up on the stack to see if we are being called from
-        a SubPathExpr, and if so, return None instead of raising a
-        NotFoundError.
-
-        Otherwise, raise a Zope2 zExceptions.NotFound error.
+        Just raise a AttributeError and let Zope do it's job.
         """
-
-        import inspect
-        frame = inspect.currentframe()
-        try:
-            while frame is not None:
-                context = frame.f_locals.get('self', _marker)
-                if (context is not _marker and
-                    isinstance(context, SubPathExpr)):
-                    # We are being called from a SubPathExpr.  Return
-                    # None instead of raising a NotFoundError, because
-                    # no __bobo_traverse__ caller expects an
-                    # exception. See more below.
-                    return None
-                frame = frame.f_back
-            # If we got this far, we are being called from something
-            # else that isn't a SubPathExpr.  None of the
-            # __bobo_traverse__ callers expect to get an
-            # exception. Instead, they *always* expect to get an
-            # object.  However, for BaseRequest, if we return None,
-            # instead of getting a NotFoundError, we will get an
-            # exception complaining about a missing docstring. Thus,
-            # we raise the NotFoundError ourselves.
-            return REQUEST.RESPONSE.notFoundError(name)
-        finally:
-            del frame
-            del context
+        raise AttributeError, name
 
     def __bobo_traverse__(self, REQUEST, name):
         """Hook for Zope 2 traversal


More information about the z3-checkins mailing list