Commit 759b71a3 authored by Florent Guillaume's avatar Florent Guillaume

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.
parent d1944098
......@@ -11,6 +11,12 @@ Bugfixes
* 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)
======================
......
......@@ -19,6 +19,11 @@ import os, sys
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 @@ def test_traversable():
... <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 @@ def test_traversable():
>>> 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():
......
......@@ -269,12 +269,14 @@ def killMonkey(class_, name, fallback, attr=None):
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:
......
......@@ -25,13 +25,14 @@ from zope.app.component.interfaces import IPossibleSite
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 @@ def installSiteHook(_context, class_, site_class=None):
callable = classImplements,
args=(class_, IPossibleSite)
)
_localsite_monkies.append(class_)
# clean up code
......
......@@ -57,6 +57,7 @@ class Traversable:
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment