[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/t "surface" portion
of the move to METAL 1.1: macro extension requires the
Fred L. Drake, Jr.
fdrake at gmail.com
Fri Aug 19 16:29:36 EDT 2005
Log message for revision 38009:
"surface" portion of the move to METAL 1.1: macro extension requires the
extend-macro attribute instead of use-macro, and cannot be combined with
use-macro
Changed:
U Zope3/trunk/src/zope/tal/taldefs.py
U Zope3/trunk/src/zope/tal/talgenerator.py
U Zope3/trunk/src/zope/tal/tests/input/acme_template.pt
U Zope3/trunk/src/zope/tal/tests/input/test_metal9.html
U Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py
-=-
Modified: Zope3/trunk/src/zope/tal/taldefs.py
===================================================================
--- Zope3/trunk/src/zope/tal/taldefs.py 2005-08-19 18:38:38 UTC (rev 38008)
+++ Zope3/trunk/src/zope/tal/taldefs.py 2005-08-19 20:29:35 UTC (rev 38009)
@@ -36,6 +36,7 @@
# TODO: In Python 2.4 we can use frozenset() instead of dict.fromkeys()
KNOWN_METAL_ATTRIBUTES = dict.fromkeys([
"define-macro",
+ "extend-macro",
"use-macro",
"define-slot",
"fill-slot",
Modified: Zope3/trunk/src/zope/tal/talgenerator.py
===================================================================
--- Zope3/trunk/src/zope/tal/talgenerator.py 2005-08-19 18:38:38 UTC (rev 38008)
+++ Zope3/trunk/src/zope/tal/talgenerator.py 2005-08-19 20:29:35 UTC (rev 38009)
@@ -508,6 +508,7 @@
todo = {}
defineMacro = metaldict.get("define-macro")
+ extendMacro = metaldict.get("extend-macro")
useMacro = metaldict.get("use-macro")
defineSlot = metaldict.get("define-slot")
fillSlot = metaldict.get("fill-slot")
@@ -537,12 +538,25 @@
raise I18NError("i18n:data must be accompanied by i18n:translate",
position)
- if defineMacro or useMacro:
+ if extendMacro:
+ if useMacro:
+ raise METALError(
+ "extend-macro cannot be used with use-macro", position)
+ if not defineMacro:
+ raise METALError(
+ "extend-macro must be used with define-macro", position)
+
+ if defineMacro or extendMacro or useMacro:
if fillSlot or defineSlot:
raise METALError(
"define-slot and fill-slot cannot be used with "
- "define-macro or use-macro", position)
+ "define-macro, extend-macro, or use-macro", position)
+ if defineMacro and useMacro:
+ raise METALError(
+ "define-macro may not be used with use-macro", position)
+ useMacro = useMacro or extendMacro
+
if content and msgid:
raise I18NError(
"explicit message id and tal:content can't be used together",
Modified: Zope3/trunk/src/zope/tal/tests/input/acme_template.pt
===================================================================
--- Zope3/trunk/src/zope/tal/tests/input/acme_template.pt 2005-08-19 18:38:38 UTC (rev 38008)
+++ Zope3/trunk/src/zope/tal/tests/input/acme_template.pt 2005-08-19 20:29:35 UTC (rev 38009)
@@ -1,6 +1,6 @@
<!-- This is ACME's generic look and feel, which is based on
PNOME's look and feel. -->
-<html metal:use-macro="pnome_macros_page" metal:define-macro="page">
+<html metal:extend-macro="pnome_macros_page" metal:define-macro="page">
<head>
<title metal:fill-slot="title">ACME Look and Feel</title>
</head>
Modified: Zope3/trunk/src/zope/tal/tests/input/test_metal9.html
===================================================================
--- Zope3/trunk/src/zope/tal/tests/input/test_metal9.html 2005-08-19 18:38:38 UTC (rev 38008)
+++ Zope3/trunk/src/zope/tal/tests/input/test_metal9.html 2005-08-19 20:29:35 UTC (rev 38009)
@@ -4,7 +4,7 @@
</span>
</div>
-<div metal:define-macro="macro2" metal:use-macro="macro1" i18n:domain="zope">
+<div metal:define-macro="macro2" metal:extend-macro="macro1" i18n:domain="zope">
<span metal:fill-slot="slot1">
Macro 2's slot 1 decoration
<span metal:define-slot="slot1">
Modified: Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py 2005-08-19 18:38:38 UTC (rev 38008)
+++ Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py 2005-08-19 20:29:35 UTC (rev 38009)
@@ -557,6 +557,18 @@
self._should_error("<p metal:foobar='x' />", exc)
self._should_error("<p metal:define-macro='x'>", exc)
+ def test_extend_macro_errors(self):
+ exc = taldefs.METALError
+ # extend-macro requires define-macro:
+ self._should_error("<p metal:extend-macro='x'>xxx</p>", exc)
+ # extend-macro prevents use-macro:
+ self._should_error("<p metal:extend-macro='x'"
+ " metal:use-macro='x'"
+ " metal:define-macro='y'>xxx</p>", exc)
+ # use-macro doesn't co-exist with define-macro:
+ self._should_error("<p metal:use-macro='x'"
+ " metal:define-macro='y'>xxx</p>", exc)
+
#
# I18N test cases
#
More information about the Zope3-Checkins
mailing list