Commit f2d029ba authored by David Glick's avatar David Glick

fix regression introduced in merge of philikon-aq branch; implicit acquirers...

fix regression introduced in merge of philikon-aq branch; implicit acquirers looked up as named adapters still need an acquisition wrapper.  see http://plone.org/support/forums/core#nabble-td1473889|a1479594 and following for discussion.
parent e9ed54f5
......@@ -96,6 +96,8 @@ class DefaultPublishTraverse(object):
request.response.setStatus(200)
# We don't need to do the docstring security check
# for views, so lets skip it and return the object here.
if IAcquirer.providedBy(subobject):
subobject = subobject.__of__(object)
return subobject
# No view found. Reraise the error raised by __bobo_traverse__
raise e
......@@ -109,6 +111,8 @@ class DefaultPublishTraverse(object):
subobject = queryMultiAdapter((object, request), Interface,
name)
if subobject is not None:
if IAcquirer.providedBy(subobject):
subobject = subobject.__of__(object)
return subobject
# And lastly, of there is no view, try acquired attributes, but
......
......@@ -295,6 +295,8 @@ class TestBaseRequestZope3Views(unittest.TestCase):
zope.interface.Interface, 'page2')
gsm.registerAdapter(DummyPage3, (IDummy, IDefaultBrowserLayer),
zope.interface.Interface, 'page3')
gsm.registerAdapter(DummyPage4, (IDummy, IDefaultBrowserLayer),
zope.interface.Interface, 'page4')
# Bind the 'view' namespace (for @@ traversal)
gsm.registerAdapter(zope.traversing.namespace.view,
......@@ -419,6 +421,18 @@ class TestBaseRequestZope3Views(unittest.TestCase):
ob = r.traverse('folder/obj/page3')
self.assertEqual(ob(), 'Test page')
def test_wrapping_implicit_acquirers(self):
# when the default publish traverser finds via adaptation
# an object providing IAcquirer, it should wrap it in the
# object being traversed
root, folder = self._makeRootAndFolder()
ob2 = DummyObjectZ3('ob2')
folder._setObject('ob2', ob2)
r = self._makeOne(root)
ob = r.traverse('folder/page4')
self.assertEqual(ob(), 'Test page')
# make sure we can acquire
self.assertEqual(ob.ob2, ob2)
class DummyResponse(Implicit):
......@@ -576,6 +590,9 @@ class DummyPage3(BrowserPage):
# __call__ remains unimplemented, baseclass raises NotImplementedError
class DummyPage4(Implicit, DummyPage):
# a normal page that can implicitly acquire attributes
pass
def test_suite():
return unittest.TestSuite((
......
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