[z3-checkins] r21753 - in z3/Five/branch/Five-1.3: . browser/tests

efge at codespeak.net efge at codespeak.net
Fri Jan 6 18:58:06 CET 2006


Author: efge
Date: Fri Jan  6 18:58:06 2006
New Revision: 21753

Modified:
   z3/Five/branch/Five-1.3/CHANGES.txt
   z3/Five/branch/Five-1.3/browser/tests/test_traversable.py
   z3/Five/branch/Five-1.3/fiveconfigure.py
   z3/Five/branch/Five-1.3/traversable.py
Log:
Fix cleanup of five:traversable.

Modified: z3/Five/branch/Five-1.3/CHANGES.txt
==============================================================================
--- z3/Five/branch/Five-1.3/CHANGES.txt	(original)
+++ z3/Five/branch/Five-1.3/CHANGES.txt	Fri Jan  6 18:58:06 2006
@@ -11,8 +11,11 @@
 * Fix functional test for local sites and re-enable it for standard
   test runs.
 
-* If one class was set to have a localsite hook twice, removing the hook would be
-  attempted twice during the cleanup of unit tests, and the tests would fail.
+* If one class was set to have a localsite hook twice, removing the hook
+  would be attempted twice during the cleanup of unit tests, and the
+  tests would fail.
+
+* Fix cleanup of five:traversable.
 
 Five 1.3c (2005-12-06)
 ======================

Modified: z3/Five/branch/Five-1.3/browser/tests/test_traversable.py
==============================================================================
--- z3/Five/branch/Five-1.3/browser/tests/test_traversable.py	(original)
+++ z3/Five/branch/Five-1.3/browser/tests/test_traversable.py	Fri Jan  6 18:58:06 2006
@@ -19,6 +19,11 @@
 if __name__ == '__main__':
     execfile(os.path.join(sys.path[0], 'framework.py'))
 
+
+class SimpleClass(object):
+    """Class with no __bobo_traverse__."""
+
+
 def test_traversable():
     """
     Test the behaviour of Five-traversable classes.
@@ -56,6 +61,9 @@
       ... <five:traversable
       ...     class="Products.Five.tests.testing.fancycontent.FancyContent"
       ...     />
+      ... <five:traversable
+      ...     class="Products.Five.browser.tests.test_traversable.SimpleClass"
+      ...     />
       ... 
       ... <browser:page
       ...     for="Products.Five.tests.testing.fancycontent.IFancyContent"
@@ -96,6 +104,22 @@
 
       >>> from zope.app.testing.placelesssetup import tearDown
       >>> tearDown()
+
+    Verify that after cleanup, there's no cruft left from five:traversable::
+
+      >>> from Products.Five.browser.tests.test_traversable import SimpleClass
+      >>> hasattr(SimpleClass, '__bobo_traverse__')
+      False
+      >>> hasattr(SimpleClass, '__fallback_traverse__')
+      False
+
+      >>> from Products.Five.tests.testing.fancycontent import FancyContent
+      >>> hasattr(FancyContent, '__bobo_traverse__')
+      True
+      >>> hasattr(FancyContent.__bobo_traverse__, '__five_method__')
+      False
+      >>> hasattr(FancyContent, '__fallback_traverse__')
+      False
     """
 
 def test_suite():

Modified: z3/Five/branch/Five-1.3/fiveconfigure.py
==============================================================================
--- z3/Five/branch/Five-1.3/fiveconfigure.py	(original)
+++ z3/Five/branch/Five-1.3/fiveconfigure.py	Fri Jan  6 18:58:06 2006
@@ -269,12 +269,14 @@
     method = getattr(class_, name, None)
     if isFiveMethod(method):
         original = getattr(class_, fallback, None)
-        if original is None:
+        if original is not None:
+            delattr(class_, fallback)
+        if original is None or isFiveMethod(original):
             try:
                 delattr(class_, name)
             except AttributeError:
                 pass
-        else:                
+        else:
             setattr(class_, name, original)
 
     if attr is not None:

Modified: z3/Five/branch/Five-1.3/traversable.py
==============================================================================
--- z3/Five/branch/Five-1.3/traversable.py	(original)
+++ z3/Five/branch/Five-1.3/traversable.py	Fri Jan  6 18:58:06 2006
@@ -57,6 +57,7 @@
         and let Zope do it's job.
         """
         raise AttributeError, name
+    __fallback_traverse__.__five_method__ = True
 
     def __bobo_traverse__(self, REQUEST, name):
         """Hook for Zope 2 traversal


More information about the z3-checkins mailing list