[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/Five/ Sync with
Five 1.3 r21753:
Florent Guillaume
fg at nuxeo.com
Fri Jan 6 13:17:32 EST 2006
Log message for revision 41170:
Sync with Five 1.3 r21753:
r21753 | efge | 2006-01-06 18:58:06 +0100 (Fri, 06 Jan 2006)
Fix cleanup of five:traversable.
r21752 | regebro | 2006-01-06 18:51:19 +0100 (Fri, 06 Jan 2006)
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.
Changed:
U Zope/trunk/lib/python/Products/Five/CHANGES.txt
U Zope/trunk/lib/python/Products/Five/browser/tests/test_traversable.py
U Zope/trunk/lib/python/Products/Five/fiveconfigure.py
U Zope/trunk/lib/python/Products/Five/site/metaconfigure.py
U Zope/trunk/lib/python/Products/Five/traversable.py
-=-
Modified: Zope/trunk/lib/python/Products/Five/CHANGES.txt
===================================================================
--- Zope/trunk/lib/python/Products/Five/CHANGES.txt 2006-01-06 18:16:11 UTC (rev 41169)
+++ Zope/trunk/lib/python/Products/Five/CHANGES.txt 2006-01-06 18:17:32 UTC (rev 41170)
@@ -11,6 +11,12 @@
* 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.
+
+* Fix cleanup of five:traversable.
+
Five 1.3c (2005-12-06)
======================
Modified: Zope/trunk/lib/python/Products/Five/browser/tests/test_traversable.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/browser/tests/test_traversable.py 2006-01-06 18:16:11 UTC (rev 41169)
+++ Zope/trunk/lib/python/Products/Five/browser/tests/test_traversable.py 2006-01-06 18:17:32 UTC (rev 41170)
@@ -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: Zope/trunk/lib/python/Products/Five/fiveconfigure.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/fiveconfigure.py 2006-01-06 18:16:11 UTC (rev 41169)
+++ Zope/trunk/lib/python/Products/Five/fiveconfigure.py 2006-01-06 18:17:32 UTC (rev 41170)
@@ -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: Zope/trunk/lib/python/Products/Five/site/metaconfigure.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/site/metaconfigure.py 2006-01-06 18:16:11 UTC (rev 41169)
+++ Zope/trunk/lib/python/Products/Five/site/metaconfigure.py 2006-01-06 18:17:32 UTC (rev 41170)
@@ -25,13 +25,14 @@
from Products.Five.site.localsite import FiveSite
+_localsite_monkies = []
def classSiteHook(class_, site_class):
setattr(class_, 'getSiteManager',
site_class.getSiteManager.im_func)
setattr(class_, 'setSiteManager',
site_class.setSiteManager.im_func)
+ _localsite_monkies.append(class_)
-_localsite_monkies = []
def installSiteHook(_context, class_, site_class=None):
if site_class is None:
if not IPossibleSite.implementedBy(class_):
@@ -53,7 +54,6 @@
callable = classImplements,
args=(class_, IPossibleSite)
)
- _localsite_monkies.append(class_)
# clean up code
Modified: Zope/trunk/lib/python/Products/Five/traversable.py
===================================================================
--- Zope/trunk/lib/python/Products/Five/traversable.py 2006-01-06 18:16:11 UTC (rev 41169)
+++ Zope/trunk/lib/python/Products/Five/traversable.py 2006-01-06 18:17:32 UTC (rev 41170)
@@ -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 Zope-Checkins
mailing list