On 30 September 2011 13:42, Robert Forkel <[email protected]> wrote:
> hi all,
> just ran into an issue which may be of interest for others too. While
> using deform with chameleon 2.x does work for me, i18n message
> extraction with lingua for templates does generally not. This is
> because the lingua_xml extractor will only work with well-formed xml
> which many deform templates are not (checkbox_choice.pt e.g. does not
> have a single root element).
It's easy to plug in to Chameleon's parser.
If `source` is a text string and `filename` is the corresponding
filename (if applicable), the following spits out events "start_tag",
"end_tag", "element", "empty_tag", "comment", "text" etc. along with
the corresponding event data.
from chameleon.tokenize import iter_xml
from chameleon.parser import ElementParser
from chameleon import namespaces
default_namespaces = {
'xmlns': namespaces.XMLNS_NS,
'xml': namespaces.XML_NS,
'tal': namespaces.TAL,
'metal': namespaces.METAL,
'i18n': namespaces.I18N,
'meta': namespacesMETA,
}
tokens = iter_xml(source, filename)
parser = ElementParser(tokens, default_namespaces)
for event, args in parser:
print "visit_%s%r" % (event, args)
\malthe
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en.