[Zope-CVS] CVS: Products/CompositePage/tests - test_macro.py:1.4

Shane Hathaway shane at zope.com
Tue Mar 2 15:42:15 EST 2004


Update of /cvs-repository/Products/CompositePage/tests
In directory cvs.zope.org:/tmp/cvs-serv26507/tests

Modified Files:
	test_macro.py 
Log Message:
Switched to use composite element objects.

Composites no longer hold arbitrary objects.  They hold
composite elements, which reference arbitrary objects.  This makes
it unnecessary to store annotations, use any kind of adapter framework,
or depend on the References product.  Composite elements are
usually references.


=== Products/CompositePage/tests/test_macro.py 1.3 => 1.4 ===
--- Products/CompositePage/tests/test_macro.py:1.3	Sat Dec 27 17:56:44 2003
+++ Products/CompositePage/tests/test_macro.py	Tue Mar  2 15:41:44 2004
@@ -21,9 +21,10 @@
 import ZODB
 from OFS.Folder import Folder
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
-from Products.CompositePage.macro import renderMacro
+from Products.CompositePage.macro import getRootMacro, renderMacro
 from Products.CompositePage.slot import Slot
 from Products.CompositePage.composite import Composite
+from Products.CompositePage.element import CompositeElement
 from AccessControl.SecurityManagement import noSecurityManager
 from AccessControl.SecurityManager import setSecurityPolicy
 import AccessControl.User  # Get the "nobody" user defined
@@ -31,7 +32,7 @@
 from Products.CompositePage.tests.test_tool import PermissiveSecurityPolicy
 
 
-template_text = '''
+template_text = '''\
 <html metal:define-macro="page">
 <body>
 <div metal:define-slot="slot_a">slot_a</div>
@@ -53,7 +54,9 @@
             id="template", text=template_text, content_type="text/html")
         f.composite.filled_slots.slot_a = slot_a = Slot("slot_a")
         a1 = ZopePageTemplate(id="a1", text="<b>Slot A</b>")
-        slot_a._setObject(a1.id, a1)
+        f._setObject(a1.id, a1)
+        e1 = CompositeElement('e1', f.a1)
+        slot_a._setObject(e1.id, e1)
         self.composite = f.composite
         self.old_policy = setSecurityPolicy(PermissiveSecurityPolicy())
         noSecurityManager()
@@ -71,7 +74,9 @@
 
     def testRender(self):
         c = self.composite
-        rendered = renderMacro(c.template, "page", c)
+        macro = getRootMacro(c.template)
+        self.assert_(macro is not None, c.template)
+        rendered = renderMacro(c.template, macro, c)
         expected = ('<html><body>'
                     '<div class="slot_header"></div><div><b>Slot A</b></div>'
                     '<div class="slot_header"></div></body></html>')




More information about the Zope-CVS mailing list