[Zope3-checkins] SVN: Zope3/branches/3.3/ Fix
http://www.zope.org/Collectors/Zope3-dev/636:
Philipp von Weitershausen
philikon at philikon.de
Thu May 25 14:59:26 EDT 2006
Log message for revision 68282:
Fix http://www.zope.org/Collectors/Zope3-dev/636:
Default ITraverser can't traverse old style classes
Changed:
U Zope3/branches/3.3/doc/CHANGES.txt
U Zope3/branches/3.3/src/zope/traversing/adapters.py
U Zope3/branches/3.3/src/zope/traversing/tests/test_traverser.py
-=-
Modified: Zope3/branches/3.3/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.3/doc/CHANGES.txt 2006-05-25 18:08:02 UTC (rev 68281)
+++ Zope3/branches/3.3/doc/CHANGES.txt 2006-05-25 18:59:25 UTC (rev 68282)
@@ -10,6 +10,9 @@
Bugfixes
+ - Fixed issue 636: Default ITraverser can't traverse old style
+ classes
+
- Fixed issue 638: TALES PathExpr calls result of alternate
subexpression
Modified: Zope3/branches/3.3/src/zope/traversing/adapters.py
===================================================================
--- Zope3/branches/3.3/src/zope/traversing/adapters.py 2006-05-25 18:08:02 UTC (rev 68281)
+++ Zope3/branches/3.3/src/zope/traversing/adapters.py 2006-05-25 18:59:25 UTC (rev 68282)
@@ -158,7 +158,8 @@
nm = name
if traversable is None:
- if obj.__class__ == dict:
+ # not all objects have __class__, for example old style classes
+ if getattr(obj, '__class__', None) == dict:
# Special-case dicts
return obj[name]
Modified: Zope3/branches/3.3/src/zope/traversing/tests/test_traverser.py
===================================================================
--- Zope3/branches/3.3/src/zope/traversing/tests/test_traverser.py 2006-05-25 18:08:02 UTC (rev 68281)
+++ Zope3/branches/3.3/src/zope/traversing/tests/test_traverser.py 2006-05-25 18:59:25 UTC (rev 68282)
@@ -137,6 +137,15 @@
def testNotFoundNoDefault(self):
self.assertRaises(TraversalError, self.tr.traverse, 'foo')
+ def testTraverseOldStyleClass(self):
+ class AnOldStyleClass:
+ x = object()
+ container = {}
+ container['theclass'] = AnOldStyleClass
+
+ tr = Traverser(container)
+ self.assert_(tr.traverse('theclass/x') is AnOldStyleClass.x)
+
class RestrictedTraverseTests(PlacefulSetup, unittest.TestCase):
_oldPolicy = None
_deniedNames = ()
More information about the Zope3-Checkins
mailing list