[Zope-Checkins] SVN: Zope/trunk/lib/python/OFS/ follow-up to r92860...unrestrictedTraverse also needs to acquisition-wrap implicit acquirers found via adaptation (fixing regression from merge of philikon-aq branch)
David Glick
davidglick at onenw.org
Fri Nov 14 03:22:20 EST 2008
Log message for revision 92919:
follow-up to r92860...unrestrictedTraverse also needs to acquisition-wrap implicit acquirers found via adaptation (fixing regression from merge of philikon-aq branch)
Changed:
U Zope/trunk/lib/python/OFS/Traversable.py
U Zope/trunk/lib/python/OFS/tests/testTraverse.py
-=-
Modified: Zope/trunk/lib/python/OFS/Traversable.py
===================================================================
--- Zope/trunk/lib/python/OFS/Traversable.py 2008-11-13 23:44:57 UTC (rev 92918)
+++ Zope/trunk/lib/python/OFS/Traversable.py 2008-11-14 08:22:19 UTC (rev 92919)
@@ -263,6 +263,8 @@
Interface, name)
if next is not None:
+ if IAcquirer.providedBy(next):
+ next = next.__of__(obj)
if restricted and not validate(obj, obj, name, next):
raise Unauthorized(name)
elif bobo_traverse is not None:
Modified: Zope/trunk/lib/python/OFS/tests/testTraverse.py
===================================================================
--- Zope/trunk/lib/python/OFS/tests/testTraverse.py 2008-11-13 23:44:57 UTC (rev 92918)
+++ Zope/trunk/lib/python/OFS/tests/testTraverse.py 2008-11-14 08:22:19 UTC (rev 92919)
@@ -397,6 +397,7 @@
self.failUnless(
self.folder1.unrestrictedTraverse('+something') is 'plus')
+
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
@@ -468,6 +469,13 @@
... name="raise-keyerror"
... permission="zope2.Public"
... />
+ ... <!-- an item that can be traversed to via adaptation -->
+ ... <browser:page
+ ... for="*"
+ ... class="Products.Five.tests.testing.fancycontent.FancyContent"
+ ... name="acquirer"
+ ... permission="zope2.Public"
+ ... />
... </configure>'''
>>> zcml.load_string(configure_zcml)
@@ -526,7 +534,14 @@
... 'an_attribute').index_html({})
'an_attribute'
+ If we traverse to something via an adapter lookup and it provides IAcquirer,
+ it should get acquisition-wrapped so we can acquire attributes implicitly:
+
+ >>> acquirer = self.folder.unrestrictedTraverse('acquirer')
+ >>> acquirer.fancy
+ <FancyContent ...>
+
Clean up:
>>> from zope.app.testing.placelesssetup import tearDown
More information about the Zope-Checkins
mailing list