[Checkins] SVN: z3c.pt/trunk/ Static attributes are now properly overriden by py:attr-attributes.
Malthe Borch
mborch at gmail.com
Mon Aug 11 13:00:37 EDT 2008
Log message for revision 89673:
Static attributes are now properly overriden by py:attr-attributes.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/clauses.py
U z3c.pt/trunk/src/z3c/pt/translation.txt
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-08-11 16:46:14 UTC (rev 89672)
+++ z3c.pt/trunk/CHANGES.txt 2008-08-11 17:00:37 UTC (rev 89673)
@@ -4,6 +4,9 @@
Version 1.0dev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- Static attributes are now properly overriden by py:attr-attributes.
+ [malthe]
+
- String-expressions may now contain semi-colons using a double
semi-colon literal (;;). [malthe]
Modified: z3c.pt/trunk/src/z3c/pt/clauses.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/clauses.py 2008-08-11 16:46:14 UTC (rev 89672)
+++ z3c.pt/trunk/src/z3c/pt/clauses.py 2008-08-11 17:00:37 UTC (rev 89673)
@@ -468,7 +468,7 @@
self.selfclosing = selfclosing
self.attributes = attributes
- self.expression = expression
+ self.expression = expression and Assign(expression)
def begin(self, stream):
stream.out('<%s' % self.tag)
@@ -483,16 +483,28 @@
isinstance(value, types.expression),
self.attributes.items())
- for attribute, expression in static:
- stream.out(' %s="%s"' %
- (attribute,
- escape(expression, '"')))
+ if self.expression:
+ self.expression.begin(stream, '_exp')
+ names = ", ".join([repr(a) for a, e in static]+[repr(a) for a, v in dynamic])
+
+ if self.expression:
+ for attribute, expression in static:
+ stream.write("if '%s' not in _exp:" % attribute)
+ stream.indent()
+ stream.write(
+ "_write(' %s=\"%s\"')" % (attribute, escape(expression, '"')))
+ stream.outdent()
+ else:
+ for attribute, expression in static:
+ stream.out(
+ ' %s="%s"' % (attribute, escape(expression, '"')))
+
temp = stream.save()
temp2 = stream.save()
if self.expression:
- stream.write("for %s, %s in (%s).items():" % (temp, temp2, self.expression))
+ stream.write("for %s, %s in _exp.items():" % (temp, temp2))
stream.indent()
if unicode_required_flag:
stream.write("if isinstance(%s, unicode):" % temp2)
Modified: z3c.pt/trunk/src/z3c/pt/translation.txt
===================================================================
--- z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-11 16:46:14 UTC (rev 89672)
+++ z3c.pt/trunk/src/z3c/pt/translation.txt 2008-08-11 17:00:37 UTC (rev 89673)
@@ -531,7 +531,7 @@
>>> print render("""\
... <ul xmlns="http://www.w3.org/1999/xhtml"
... xmlns:py="http://genshi.edgewall.org">
- ... <li py:attrs="{'class': 'collapse'}">Bar</li>
+ ... <li class="expand" py:attrs="{'class': 'collapse'}">Bar</li>
... </ul>""", translate_xml)
<ul>
<li class="collapse">Bar</li>
More information about the Checkins
mailing list