[Checkins] SVN: z3c.pt/trunk/ No longer require default namespace.
Malthe Borch
mborch at gmail.com
Tue Aug 12 17:34:41 EDT 2008
Log message for revision 89756:
No longer require default namespace.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/translation.py
U z3c.pt/trunk/src/z3c/pt/translation.txt
U z3c.pt/trunk/src/z3c/pt/utils.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-08-12 21:25:46 UTC (rev 89755)
+++ z3c.pt/trunk/CHANGES.txt 2008-08-12 21:34:41 UTC (rev 89756)
@@ -4,6 +4,8 @@
Version 1.0dev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- No longer require default namespace. [malthe]
+
- Changed source code debug mode files to be named <filename>.py instead of
<filename>.source.
Modified: z3c.pt/trunk/src/z3c/pt/translation.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.py 2008-08-12 21:25:46 UTC (rev 89755)
+++ z3c.pt/trunk/src/z3c/pt/translation.py 2008-08-12 21:34:41 UTC (rev 89756)
@@ -590,9 +590,10 @@
tal_attributes = utils.attribute("attributes", lambda p: p.expression)
tal_content = utils.attribute("content", lambda p: p.output)
tal_omit = utils.attribute("omit-tag", lambda p: p.expression, u"")
- tal_default_expression = utils.attribute("default-expression", lambda p: p.name)
+ tal_default_expression = utils.attribute(
+ 'default-expression')
tal_cdata = utils.attribute("cdata")
-
+
def _get_static_attributes(self):
attributes = {}
@@ -604,6 +605,7 @@
'attributes',
'content',
'omit-tag',
+ 'default-expression',
'cdata'):
raise ValueError(
u"Attribute '%s' not allowed in the namespace '%s'" %
@@ -652,8 +654,8 @@
def translate_etree(root, macro=None, doctype=None,
params=[], default_expression='python'):
- if None not in root.nsmap:
- raise ValueError, "Must set default namespace."
+ if not isinstance(root, Element):
+ raise ValueError("Must define valid namespace for tag: '%s.'" % root.tag)
# skip to macro
if macro is not None:
@@ -668,9 +670,8 @@
del root.attrib[utils.metal_attr('define-macro')]
# set default expression name
- key = utils.tal_attr('default-expression')
- if key not in root.attrib:
- root.attrib[key] = default_expression
+ if not root.tal_default_expression:
+ root.tal_default_expression = default_expression
# set up code generation stream
if macro is not None:
Modified: z3c.pt/trunk/src/z3c/pt/translation.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-12 21:25:46 UTC (rev 89755)
+++ z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-12 21:34:41 UTC (rev 89756)
@@ -140,6 +140,16 @@
Zope TAL
--------
+:: Namespace elements
+
+ >>> print render("""\
+ ... <tal:block xmlns:tal="http://xml.zope.org/namespaces/tal">
+ ... Hello, world!
+ ... </tal:block>""", translate_xml)
+ <BLANKLINE>
+ Hello, world!
+ <BLANKLINE>
+
tal:define, tal:attributes, tal:contents
>>> print render("""\
@@ -730,7 +740,7 @@
>>> render(body, translate_xml)
Traceback (most recent call last):
...
- ValueError: Must set default namespace.
+ ValueError: Must define valid namespace for tag: 'br.'
Bad XML
We expect the xml-parser to raise an exception.
Modified: z3c.pt/trunk/src/z3c/pt/utils.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/utils.py 2008-08-12 21:25:46 UTC (rev 89755)
+++ z3c.pt/trunk/src/z3c/pt/utils.py 2008-08-12 21:34:41 UTC (rev 89756)
@@ -36,8 +36,9 @@
return f(value)
elif default is not None:
return default
-
- return property(get)
+ def set(self, value):
+ self.attrib[ns] = value
+ return property(get, set)
class scope(list):
def __init__(self, *args):
More information about the Checkins
mailing list