[Checkins] SVN: z3c.pt/trunk/ The compiler now expects a parser instance.
Malthe Borch
mborch at gmail.com
Mon Sep 1 05:17:14 EDT 2008
Log message for revision 90636:
The compiler now expects a parser instance.
Changed:
U z3c.pt/trunk/CHANGES.txt
U z3c.pt/trunk/src/z3c/pt/etree.py
U z3c.pt/trunk/src/z3c/pt/testing.py
U z3c.pt/trunk/src/z3c/pt/zpt.py
-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt 2008-09-01 09:16:09 UTC (rev 90635)
+++ z3c.pt/trunk/CHANGES.txt 2008-09-01 09:17:13 UTC (rev 90636)
@@ -4,6 +4,10 @@
Version 1.0dev
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Backwards incompatibilities
+
+- The compiler now expects an instantiated parser instance. [malthe]
+
Features
- Added ``symbol_mapping`` attribute to code streams such that
Modified: z3c.pt/trunk/src/z3c/pt/etree.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/etree.py 2008-09-01 09:16:09 UTC (rev 90635)
+++ z3c.pt/trunk/src/z3c/pt/etree.py 2008-09-01 09:17:13 UTC (rev 90636)
@@ -17,11 +17,10 @@
return ET
class Parser(object):
- element_mapping = {}
+ element_mapping = utils.emptydict()
- @classmethod
- def parse(cls, body):
- return parse(body, cls.element_mapping)
+ def parse(self, body):
+ return parse(body, self.element_mapping)
try:
import lxml.etree
Modified: z3c.pt/trunk/src/z3c/pt/testing.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/testing.py 2008-09-01 09:16:09 UTC (rev 90635)
+++ z3c.pt/trunk/src/z3c/pt/testing.py 2008-09-01 09:17:13 UTC (rev 90636)
@@ -25,22 +25,22 @@
return out, write, stream
def render_xhtml(body, **kwargs):
- compiler = translation.Compiler(body, MockParser)
+ compiler = translation.Compiler(body, mock_parser)
template = compiler(params=sorted(kwargs.keys()))
return template.render(**kwargs)
def render_text(body, **kwargs):
- compiler = translation.Compiler.from_text(body, MockParser)
+ compiler = translation.Compiler.from_text(body, mock_parser)
template = compiler(params=sorted(kwargs.keys()))
return template.render(**kwargs)
def render_zpt(body, **kwargs):
- compiler = translation.Compiler(body, zpt.ZopePageTemplateParser)
+ compiler = translation.Compiler(body, zpt.ZopePageTemplateParser())
template = compiler(params=sorted(kwargs.keys()))
return template.render(**kwargs)
def render_genshi(body, **kwargs):
- compiler = translation.Compiler(body, genshi.GenshiParser)
+ compiler = translation.Compiler(body, genshi.GenshiParser())
template = compiler(params=sorted(kwargs.keys()))
kwargs.update(template.selectors)
return template.render(**kwargs)
@@ -109,3 +109,5 @@
config.XHTML_NS: {None: MockElement},
config.META_NS: {None: MockElement},
config.XI_NS: {None: MockElement}}
+
+mock_parser = MockParser()
Modified: z3c.pt/trunk/src/z3c/pt/zpt.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/zpt.py 2008-09-01 09:16:09 UTC (rev 90635)
+++ z3c.pt/trunk/src/z3c/pt/zpt.py 2008-09-01 09:17:13 UTC (rev 90636)
@@ -199,9 +199,8 @@
if default_expression is not None:
self.default_expression = default_expression
- @classmethod
- def parse(cls, body):
- root, doctype = super(ZopePageTemplateParser, cls).parse(body)
+ def parse(self, body):
+ root, doctype = super(ZopePageTemplateParser, self).parse(body)
# if a default expression is not set explicitly in the
# template, use the TAL-attribute ``default-expression``
@@ -212,6 +211,6 @@
tag = utils.tal_attr('default-expression')
if not root.attrib.get(tag):
- root.attrib[tag] = cls.default_expression
+ root.attrib[tag] = self.default_expression
return root, doctype
More information about the Checkins
mailing list