[Zope-Checkins]
SVN: Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy
Test the acquisition legacy stuff on templates.
Philipp von Weitershausen
philikon at philikon.de
Thu Aug 30 16:00:34 EDT 2007
Log message for revision 79387:
Test the acquisition legacy stuff on templates.
Minor cleanup.
Changed:
U Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py
U Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml
U Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt
-=-
Modified: Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py 2007-08-30 15:21:55 UTC (rev 79386)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.py 2007-08-30 20:00:34 UTC (rev 79387)
@@ -22,18 +22,21 @@
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
class LegacyAttributes(BrowserView):
- """Make sure that accessing those old aq_* attributes on Five
- BrowserViews still works, even though BrowserView may not be an
- Acquisition-decendant class anymore...
+ """Make sure that those old aq_* attributes on Five BrowserViews
+ still work, in particular aq_chain, even though BrowserView may
+ not be an Acquisition-decendant class anymore...
"""
def __call__(self):
- assert self.aq_parent == self.context
- assert self.aq_inner == self
- assert self.aq_base == self
- assert self.aq_self == self
return repr([obj for obj in self.aq_chain])
+class LegacyTemplate(BrowserView):
+
+ template = ViewPageTemplateFile('falcon.pt')
+
+ def __call__(self):
+ return self.template()
+
class Explicit(Acquisition.Explicit):
def render(self):
Modified: Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml
===================================================================
--- Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml 2007-08-30 15:21:55 UTC (rev 79386)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy.zcml 2007-08-30 20:00:34 UTC (rev 79387)
@@ -10,6 +10,13 @@
<browser:page
for="*"
+ name="template"
+ class=".aqlegacy.LegacyTemplate"
+ permission="zope.Public"
+ />
+
+ <browser:page
+ for="*"
name="explicit"
class=".aqlegacy.Explicit"
attribute="render"
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-08-30 15:21:55 UTC (rev 79386)
+++ Zope/branches/philikon-aq/lib/python/Products/Five/browser/tests/aqlegacy_ftest.txt 2007-08-30 20:00:34 UTC (rev 79387)
@@ -21,7 +21,10 @@
>>> browser.open('http://localhost/test_folder_1_/attributes')
>>> print browser.contents
- [<Products.Five.metaclass.LegacyAttributes object at ...>, <Folder at /test_folder_1_>, <Application at >, <ZPublisher.BaseRequest.RequestContainer object at ...>]
+ [<Products.Five.metaclass.LegacyAttributes object at ...>,
+ <Folder at /test_folder_1_>,
+ <Application at >,
+ <ZPublisher.BaseRequest.RequestContainer object at ...>]
Let's do some more manual tests with the view object. But first we
must get it:
@@ -31,6 +34,17 @@
>>> request = TestRequest()
>>> view = getMultiAdapter((self.folder, request), name='attributes')
+Let's check for the various aq_* attributes:
+
+ >>> view.aq_parent == self.folder
+ True
+ >>> view.aq_inner == view
+ True
+ >>> view.aq_base == view
+ True
+ >>> view.aq_self == view
+ True
+
Let's try to acquire something from the root folder:
>>> button = view.aq_acquire('ZopeAttributionButton')
@@ -51,6 +65,28 @@
>>> view == view.__of__(self.app)
True
+Acquisition API legacy on a browser view's template
+---------------------------------------------------
+
+A view's template will also support the various aq_* attributes:
+
+ >>> view = getMultiAdapter((self.folder, request), name='template')
+ >>> template = view.template
+
+ >>> template.aq_parent == view
+ True
+ >>> template.aq_inner == template
+ True
+ >>> template.aq_base == template
+ True
+ >>> template.aq_self == template
+ True
+
+ >>> button = template.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>
+
+
Mixing in Acquisition.{Ex|Im}plicit
-----------------------------------
More information about the Zope-Checkins
mailing list