Commit bf2a6131 authored by Guido van Rossum's avatar Guido van Rossum

Properly implement insertStructure. Exception: attribute replacement

still isn't supported when using replace -- too bad.
parent be5b8dfd
...@@ -90,6 +90,7 @@ import sys ...@@ -90,6 +90,7 @@ import sys
import string import string
import getopt import getopt
import cgi import cgi
from XMLParser import XMLParser
BOOLEAN_HTML_ATTRS = [ BOOLEAN_HTML_ATTRS = [
# List of Boolean attributes in HTML that should be rendered in # List of Boolean attributes in HTML that should be rendered in
...@@ -226,21 +227,26 @@ class TALInterpreter: ...@@ -226,21 +227,26 @@ class TALInterpreter:
text = cgi.escape(text) text = cgi.escape(text)
self.stream_write(text) self.stream_write(text)
def do_insertStructure(self, expr, block): def do_insertStructure(self, expr, repldict, block):
if not self.tal: if not self.tal:
self.interpret(block) self.interpret(block)
return return
structure = self.engine.evaluateStructure(expr) structure = self.engine.evaluateStructure(expr)
if structure is None: if structure is None:
return return
raise TALError("insertStructure() not implemented") if repldict:
program, macros = XXX # not implemented raise TALError(
saveMacros = self.macros "replace structure with attribute replacements not yet implemented")
if macros: text = str(structure)
self.macros = saveMacros.copy() self.checkXMLSyntax(text)
self.macros.update(macros) self.stream_write(text) # No quoting -- this is intentional
self.interpret(program)
self.macros = saveMacros def checkXMLSyntax(self, text):
# XXX This is a bit of a hack!
text = '<!DOCTYPE foo PUBLIC "foo" "bar"><foo>%s</foo>' % text
p = XMLParser()
p.parseString(text)
# If this succeeds without errors, we're fine
def do_loop(self, name, expr, block): def do_loop(self, name, expr, block):
if not self.tal: if not self.tal:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment