[Zope3-checkins] SVN: Zope3/trunk/src/zope/ fix the semantics of
macro extension to match the METAL 1.1 specification
Fred L. Drake, Jr.
fdrake at gmail.com
Fri Aug 19 18:24:30 EDT 2005
Log message for revision 38012:
fix the semantics of macro extension to match the METAL 1.1 specification
Changed:
U Zope3/trunk/src/zope/app/ftesting.zcml
A Zope3/trunk/src/zope/app/pagetemplate/ftests/
A Zope3/trunk/src/zope/app/pagetemplate/ftests/__init__.py
A Zope3/trunk/src/zope/app/pagetemplate/ftests/configure.zcml
A Zope3/trunk/src/zope/app/pagetemplate/ftests/inner.pt
A Zope3/trunk/src/zope/app/pagetemplate/ftests/intermediate.pt
A Zope3/trunk/src/zope/app/pagetemplate/ftests/outer.pt
A Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.py
A Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.txt
U Zope3/trunk/src/zope/tal/talinterpreter.py
U Zope3/trunk/src/zope/tal/tests/output/test_metal9.html
U Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
-=-
Modified: Zope3/trunk/src/zope/app/ftesting.zcml
===================================================================
--- Zope3/trunk/src/zope/app/ftesting.zcml 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/ftesting.zcml 2005-08-19 22:24:30 UTC (rev 38012)
@@ -5,5 +5,6 @@
>
<include package=".container.browser.ftests" />
+<include package=".pagetemplate.ftests" />
</configure>
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/__init__.py 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/__init__.py 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1 @@
+# This directory is a Python package.
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/__init__.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/configure.zcml
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/configure.zcml 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/configure.zcml 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,24 @@
+<configure xmlns="http://namespaces.zope.org/browser">
+
+ <page
+ for="zope.interface.Interface"
+ name="inner"
+ template="inner.pt"
+ permission="zope.Public"
+ />
+
+ <page
+ for="zope.interface.Interface"
+ name="intermediate"
+ template="intermediate.pt"
+ permission="zope.Public"
+ />
+
+ <page
+ for="zope.interface.Interface"
+ name="outer"
+ template="outer.pt"
+ permission="zope.Public"
+ />
+
+</configure>
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/configure.zcml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/inner.pt
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/inner.pt 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/inner.pt 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,8 @@
+<html metal:use-macro='context/@@intermediate/intermediate'>
+<body>
+hello
+<div metal:fill-slot="body">
+inner body slot content
+</div>
+</body>
+</html>
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/inner.pt
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/intermediate.pt
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/intermediate.pt 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/intermediate.pt 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,12 @@
+<html metal:define-macro='intermediate'
+ metal:extend-macro='context/@@outer/main'>
+<body>
+hello
+<div metal:fill-slot="body">
+<div metal:define-slot="body">
+body slot
+</div>
+intermediate body slot stuff
+</div>
+</body>
+</html>
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/intermediate.pt
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/outer.pt
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/outer.pt 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/outer.pt 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,11 @@
+<html metal:define-macro='main'>
+<head>
+<title>Example: outer</title>
+</head>
+<body>
+hello
+<div metal:define-slot="body">
+outer body slot
+</div>
+</body>
+</html>
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/outer.pt
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.py 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.py 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,10 @@
+"""Test that nested macro references do the right thing.
+"""
+__docformat__ = "reStructuredText"
+
+import zope.app.testing.functional
+
+
+def test_suite():
+ return zope.app.testing.functional.FunctionalDocFileSuite(
+ "test_nested.txt")
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.txt
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.txt 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.txt 2005-08-19 22:24:30 UTC (rev 38012)
@@ -0,0 +1,33 @@
+===============
+Macro extension
+===============
+
+This test demonstrates how macro extension allows a macro to extend
+and re-offer a slot for a client template to fill. This is likely not
+the best place for this test, but it demonstrates how to use the macro
+extension feature in context.
+
+Let's look at our test view using the root folder to make sure we're
+seeing the expected template expansion::
+
+ >>> print http("""
+ ... GET /@@inner HTTP/1.1
+ ... Authorization: Basic mgr:mgrpw
+ ... """, handle_errors=False)
+ HTTP/1.1 200 ...
+ <BLANKLINE>
+ <html>
+ <head>
+ <title>Example: outer</title>
+ </head>
+ <body>
+ hello
+ <div>
+ <div>
+ inner body slot content
+ </div>
+ intermediate body slot stuff
+ </div>
+ </body>
+ </html>
+ <BLANKLINE>
Property changes on: Zope3/trunk/src/zope/app/pagetemplate/ftests/test_nested.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py 2005-08-19 22:24:30 UTC (rev 38012)
@@ -939,12 +939,12 @@
# most general macro. The most general is at the top of
# the stack.
slot = None
- i = len_macs - depth
- while i < len_macs:
+ i = len_macs - 1
+ while i >= (len_macs - depth):
slot = macs[i].slots.get(slotName)
if slot is not None:
break
- i += 1
+ i -= 1
if slot is not None:
# Found a slot filler. Temporarily chop the macro
# stack starting at the macro that filled the slot and
Modified: Zope3/trunk/src/zope/tal/tests/output/test_metal9.html
===================================================================
--- Zope3/trunk/src/zope/tal/tests/output/test_metal9.html 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/tal/tests/output/test_metal9.html 2005-08-19 22:24:30 UTC (rev 38012)
@@ -24,6 +24,9 @@
<div metal:use-macro="macro2" i18n:domain="zope">
<span metal:fill-slot="slot1">
+Macro 2's slot 1 decoration
+<span metal:fill-slot="slot1">
Custom slot1
</span>
+</span>
</div>
Modified: Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2005-08-19 21:51:47 UTC (rev 38011)
+++ Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2005-08-19 22:24:30 UTC (rev 38012)
@@ -99,30 +99,6 @@
f.close()
return data
- def test_acme_extends_pnome(self):
- # ACME inc. has a document_list template that uses ACME's
- # common look and feel. ACME's look and feel is based on the
- # work of PNOME, Inc., a company that creates Pretty Nice
- # Object Management Environments for Zope. This test verifies
- # that document_list works as expected.
- result = StringIO()
- interpreter = TALInterpreter(
- self.doclist_program, {}, self.engine, stream=result)
- interpreter()
- actual = result.getvalue().strip()
- expected = self._read(('output', 'document_list.html')).strip()
- self.assertEqual(actual, expected)
-
- def test_acme_extends_pnome_source(self):
- # Render METAL attributes in document_list
- result = StringIO()
- interpreter = TALInterpreter(
- self.doclist_program, {}, self.engine, stream=result, tal=False)
- interpreter()
- actual = result.getvalue().strip()
- expected = self._read(('output', 'document_list_source.html')).strip()
- self.assertEqual(actual, expected)
-
def test_preview_acme_template(self):
# An ACME designer is previewing the ACME design. For the
# purposes of this use case, extending a macro should act the
More information about the Zope3-Checkins
mailing list