[Checkins] SVN: Zope/branches/philikon-aq/lib/python/Products/Five/browser/ more legacy support and tests

Philipp von Weitershausen philikon at philikon.de
Mon Jul 30 18:13:58 EDT 2007


Log message for revision 78490:
  more legacy support and tests
  

Changed:
  U   Zope/branches/philikon-aq/lib/python/Products/Five/browser/__init__.py
  U   Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt

-=-
Modified: Zope/branches/philikon-aq/lib/python/Products/Five/browser/__init__.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/browser/__init__.py	2007-07-30 22:02:14 UTC (rev 78489)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/__init__.py	2007-07-30 22:13:58 UTC (rev 78490)
@@ -32,9 +32,9 @@
 
         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 @@
     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)
 
-    @property
-    def aq_chain(self):
-        return Acquisition.aq_chain(self)
+    def aq_acquire(self, *args, **kw):
+        return Acquisition.aq_acquire(self, *args, **kw)
+
+    def aq_inContextOf(self, *args, **kw):
+        return Acquisition.aq_inContextOf(self, *args, **kw)

Modified: Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt	2007-07-30 22:02:14 UTC (rev 78489)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt	2007-07-30 22:13:58 UTC (rev 78490)
@@ -23,14 +23,29 @@
   >>> 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)



More information about the Checkins mailing list