Commit 32403ac3 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 e29c7715
...@@ -11,6 +11,12 @@ Bugfixes ...@@ -11,6 +11,12 @@ Bugfixes
* Fix functional test for local sites and re-enable it for standard * Fix functional test for local sites and re-enable it for standard
test runs. 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) Five 1.3c (2005-12-06)
====================== ======================
......
...@@ -19,6 +19,11 @@ import os, sys ...@@ -19,6 +19,11 @@ import os, sys
if __name__ == '__main__': if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py')) execfile(os.path.join(sys.path[0], 'framework.py'))
class SimpleClass(object):
"""Class with no __bobo_traverse__."""
def test_traversable(): def test_traversable():
""" """
Test the behaviour of Five-traversable classes. Test the behaviour of Five-traversable classes.
...@@ -56,6 +61,9 @@ def test_traversable(): ...@@ -56,6 +61,9 @@ def test_traversable():
... <five:traversable ... <five:traversable
... class="Products.Five.tests.testing.fancycontent.FancyContent" ... class="Products.Five.tests.testing.fancycontent.FancyContent"
... /> ... />
... <five:traversable
... class="Products.Five.browser.tests.test_traversable.SimpleClass"
... />
... ...
... <browser:page ... <browser:page
... for="Products.Five.tests.testing.fancycontent.IFancyContent" ... for="Products.Five.tests.testing.fancycontent.IFancyContent"
...@@ -96,6 +104,22 @@ def test_traversable(): ...@@ -96,6 +104,22 @@ def test_traversable():
>>> from zope.app.testing.placelesssetup import tearDown >>> from zope.app.testing.placelesssetup import tearDown
>>> 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(): def test_suite():
......
...@@ -269,7 +269,9 @@ def killMonkey(class_, name, fallback, attr=None): ...@@ -269,7 +269,9 @@ def killMonkey(class_, name, fallback, attr=None):
method = getattr(class_, name, None) method = getattr(class_, name, None)
if isFiveMethod(method): if isFiveMethod(method):
original = getattr(class_, fallback, None) 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: try:
delattr(class_, name) delattr(class_, name)
except AttributeError: except AttributeError:
......
...@@ -25,13 +25,14 @@ from zope.app.component.interfaces import IPossibleSite ...@@ -25,13 +25,14 @@ from zope.app.component.interfaces import IPossibleSite
from Products.Five.site.localsite import FiveSite from Products.Five.site.localsite import FiveSite
_localsite_monkies = []
def classSiteHook(class_, site_class): def classSiteHook(class_, site_class):
setattr(class_, 'getSiteManager', setattr(class_, 'getSiteManager',
site_class.getSiteManager.im_func) site_class.getSiteManager.im_func)
setattr(class_, 'setSiteManager', setattr(class_, 'setSiteManager',
site_class.setSiteManager.im_func) site_class.setSiteManager.im_func)
_localsite_monkies.append(class_)
_localsite_monkies = []
def installSiteHook(_context, class_, site_class=None): def installSiteHook(_context, class_, site_class=None):
if site_class is None: if site_class is None:
if not IPossibleSite.implementedBy(class_): if not IPossibleSite.implementedBy(class_):
...@@ -53,7 +54,6 @@ def installSiteHook(_context, class_, site_class=None): ...@@ -53,7 +54,6 @@ def installSiteHook(_context, class_, site_class=None):
callable = classImplements, callable = classImplements,
args=(class_, IPossibleSite) args=(class_, IPossibleSite)
) )
_localsite_monkies.append(class_)
# clean up code # clean up code
......
...@@ -57,6 +57,7 @@ class Traversable: ...@@ -57,6 +57,7 @@ class Traversable:
and let Zope do it's job. and let Zope do it's job.
""" """
raise AttributeError, name raise AttributeError, name
__fallback_traverse__.__five_method__ = True
def __bobo_traverse__(self, REQUEST, name): def __bobo_traverse__(self, REQUEST, name):
"""Hook for Zope 2 traversal """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