[Zope-Checkins]
SVN: Products.Five/branches/regebro-traversal_refactor/
Removed last rests of Traversable usage. Deprecated
Traversable and FiveTraversable.
Lennart Regebro
regebro at gmail.com
Fri Apr 28 05:25:34 EDT 2006
Log message for revision 67698:
Removed last rests of Traversable usage. Deprecated Traversable and FiveTraversable.
Changed:
U Products.Five/branches/regebro-traversal_refactor/browser/adding.py
U Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py
U Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py
U Products.Five/branches/regebro-traversal_refactor/traversable.py
-=-
Modified: Products.Five/branches/regebro-traversal_refactor/browser/adding.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/browser/adding.py 2006-04-28 08:54:44 UTC (rev 67697)
+++ Products.Five/branches/regebro-traversal_refactor/browser/adding.py 2006-04-28 09:25:33 UTC (rev 67698)
@@ -37,7 +37,7 @@
from zExceptions import BadRequest
from Products.Five import BrowserView
-from Products.Five.traversable import Traversable
+
from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile
from Acquisition import Implicit
@@ -202,7 +202,7 @@
return True
return False
-class ContentAdding(Adding, Traversable, SimpleItem):
+class ContentAdding(Adding, SimpleItem):
menu_id = "add_content"
Modified: Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-28 08:54:44 UTC (rev 67697)
+++ Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-28 09:25:33 UTC (rev 67698)
@@ -38,8 +38,6 @@
from zope.app.component.metaconfigure import adapter
from zope.app.security.interfaces import IPermission
-#from Products.Five.viewable import Viewable
-from Products.Five.traversable import Traversable
from Products.Five.bridge import fromZ2Interface
from Products.Five.browser.metaconfigure import page
from Products.Five.interfaces import IBrowserDefault
@@ -113,41 +111,10 @@
def isFiveMethod(m):
return hasattr(m, '__five_method__')
-_traversable_monkies = []
-def classTraversable(class_):
- # If a class already has this attribute, it means it is either a
- # subclass of Traversable or was already processed with this
- # directive; in either case, do nothing... except in the case were
- # the class overrides __bobo_traverse__ instead of getting it from
- # a base class. In this case, we suppose that the class probably
- # didn't bother with the base classes __bobo_traverse__ anyway and
- # we step __fallback_traverse__.
- if hasattr(class_, '__five_traversable__'):
- if (hasattr(class_, '__bobo_traverse__') and
- isFiveMethod(class_.__bobo_traverse__)):
- return
-
- if (hasattr(class_, '__bobo_traverse__') and
- not isFiveMethod(class_.__bobo_traverse__)):
- # if there's an existing bobo_traverse hook already, use that
- # as the traversal fallback method
- setattr(class_, '__fallback_traverse__', class_.__bobo_traverse__)
-
- setattr(class_, '__bobo_traverse__',
- Traversable.__bobo_traverse__.im_func)
- setattr(class_, '__five_traversable__', True)
- # remember class for clean up
- _traversable_monkies.append(class_)
-
def traversable(_context, class_):
warnings.warn("The five:traversable statement is no longer needed " \
"and will be removed in Zope 2.12",
DeprecationWarning)
- _context.action(
- discriminator = None,
- callable = classTraversable,
- args = (class_,)
- )
def defaultViewable(_context, class_):
if zope.deprecation.__show__():
@@ -259,17 +226,6 @@
except (AttributeError, KeyError):
pass
-def untraversable(class_):
- """Restore class's initial state with respect to traversability"""
- killMonkey(class_, '__bobo_traverse__', '__fallback_traverse__',
- '__five_traversable__')
-
-#def undefaultViewable(class_):
- #"""Restore class's initial state with respect to being default
- #viewable."""
- #killMonkey(class_, '__browser_default__', '__fallback_default__',
- #'__five_viewable__')
-
def unregisterClass(class_):
delattr(class_, 'meta_type')
try:
@@ -278,16 +234,7 @@
pass
def cleanUp():
- global _traversable_monkies
- for class_ in _traversable_monkies:
- untraversable(class_)
- _traversable_monkies = []
- #global _defaultviewable_monkies
- #for class_ in _defaultviewable_monkies:
- #undefaultViewable(class_)
- #_defaultviewable_monkies = []
-
global _register_monkies
for class_ in _register_monkies:
unregisterClass(class_)
Modified: Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py 2006-04-28 08:54:44 UTC (rev 67697)
+++ Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py 2006-04-28 09:25:33 UTC (rev 67698)
@@ -18,7 +18,6 @@
from OFS.Folder import Folder
from OFS.interfaces import IFolder
from zope.interface import implements
-from Products.Five.traversable import Traversable
class NoVerifyPasteFolder(Folder):
"""Folder that does not perform paste verification.
@@ -33,7 +32,7 @@
folder.id = id
folder.title = title
-class FiveTraversableFolder(Traversable, Folder):
+class FiveTraversableFolder(Folder):
"""Folder that is five-traversable
"""
implements(IFolder)
Modified: Products.Five/branches/regebro-traversal_refactor/traversable.py
===================================================================
--- Products.Five/branches/regebro-traversal_refactor/traversable.py 2006-04-28 08:54:44 UTC (rev 67697)
+++ Products.Five/branches/regebro-traversal_refactor/traversable.py 2006-04-28 09:25:33 UTC (rev 67698)
@@ -15,6 +15,10 @@
$Id$
"""
+
+import warnings
+import zope.deprecation
+
from zope.component import getMultiAdapter, ComponentLookupError
from zope.interface import implements, Interface
from zope.publisher.interfaces import ILayer
@@ -58,6 +62,13 @@
# 2. Otherwise do attribute look-up or, if that doesn't work,
# key item lookup.
+ if zope.deprecation.__show__():
+ warnings.warn("The view lookup done by Traversable." \
+ "__bobo_traverse__ is now done by the standard " \
+ "traversal. This class is no longer needed and "
+ "will be removed in Zope 2.12.",
+ DeprecationWarning, 2)
+
if hasattr(self, '__fallback_traverse__'):
try:
return self.__fallback_traverse__(REQUEST, name)
@@ -119,6 +130,14 @@
class FiveTraversable(DefaultTraversable):
+ def __init__(self, subject):
+ if zope.deprecation.__show__():
+ warnings.warn("The FiveTraversable class is no longer needed, " \
+ "and will be removed in Zope 2.12.",
+ DeprecationWarning, 2)
+
+ self._subject = subject
+
def traverse(self, name, furtherPath):
context = self._subject
__traceback_info__ = (context, name, furtherPath)
More information about the Zope-Checkins
mailing list