From 334ef4bba2df70cd8dd5c56d92bd0c9d5b598602 Mon Sep 17 00:00:00 2001
From: Philipp von Weitershausen <philipp@weitershausen.de>
Date: Mon, 30 Jul 2007 22:13:58 +0000
Subject: [PATCH] more legacy support and tests

---
 lib/python/Products/Five/browser/__init__.py  | 16 +++++++++-------
 .../Five/browser/tests/aqlegacy_ftest.txt     | 19 +++++++++++++++++--
 2 files changed, 26 insertions(+), 9 deletions(-)

diff --git a/lib/python/Products/Five/browser/__init__.py b/lib/python/Products/Five/browser/__init__.py
index 2e765395d..393c9623a 100644
--- a/lib/python/Products/Five/browser/__init__.py
+++ b/lib/python/Products/Five/browser/__init__.py
@@ -32,9 +32,9 @@ class BrowserView(zope.publisher.browser.BrowserView):
 
         return self
 
-    # XXX Classes which are still based on Acquisition and access
-    # self.context in a method need to call aq_inner on it, or get a funky
-    # aq_chain. We do this here for BBB friendly purposes.
+    # Classes which are still based on Acquisition and access
+    # self.context in a method need to call aq_inner on it, or get a
+    # funky aq_chain. We do this here for BBB friendly purposes.
 
     def __getParent(self):
         return getattr(self, '_parent', Acquisition.aq_inner(self.context))
@@ -45,9 +45,11 @@ class BrowserView(zope.publisher.browser.BrowserView):
     aq_parent = __parent__ = property(__getParent, __setParent)
 
     # We provide the aq_* properties here for BBB
-
     aq_self = aq_inner = aq_base = property(lambda self: self)
+    aq_chain = property(Acquisition.aq_chain)
+
+    def aq_acquire(self, *args, **kw):
+        return Acquisition.aq_acquire(self, *args, **kw)
 
-    @property
-    def aq_chain(self):
-        return Acquisition.aq_chain(self)
+    def aq_inContextOf(self, *args, **kw):
+        return Acquisition.aq_inContextOf(self, *args, **kw)
diff --git a/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt b/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
index b32818100..726de7e83 100644
--- a/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
+++ b/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
@@ -23,14 +23,29 @@ views still works (the printed output is the aq_chain of the view):
   >>> print browser.contents
   [<Products.Five.metaclass.LegacyAttributes object at ...>, <Folder at /test_folder_1_>, <Application at >, <ZPublisher.BaseRequest.RequestContainer object at ...>]
 
-Let's also make sure that calling __of__ on a view has the desired
-effect.  First let's get a view:
+Let's do some more manual tests with the view object.  But first we
+must get it:
 
   >>> from zope.component import getMultiAdapter
   >>> from zope.publisher.browser import TestRequest
   >>> request = TestRequest()
   >>> view = getMultiAdapter((self.folder, request), name='attributes')
 
+Let's try to acquire something from the root folder:
+
+  >>> button = view.aq_acquire('ZopeAttributionButton')
+  >>> print button()
+  <a href="http://www.zope.org/Credits" target="_top"><img src="http://nohost/p_/ZopeButton" width="115" height="50" border="0" alt="Powered by Zope" /></a>
+
+Let's check that we're in the right context:
+
+  >>> view.aq_inContextOf(self.folder)
+  1
+  >>> view.aq_inContextOf(self.app)
+  1
+  >>> view.aq_inContextOf(object())
+  0
+
 Let's try the __of__ protocol:
 
   #>>> view = view.__of__(self.app)
-- 
2.30.9