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

Give the TALInterpreter class constructor a 'strictinsert' option,

default true.  When this is false, structure insertion without
attribute replacement does not parse the inserted text.  This is
(expected to be) much faster, but allows invalid HTML/XML to be
inserted, so it is off by default.

Evan can choose to turn this on in ZPT if he's more concerned about
efficiency than about correctness. :-)
parent d6496fcc
......@@ -150,7 +150,8 @@ class AltTALGenerator(TALGenerator):
class TALInterpreter:
def __init__(self, program, macros, engine, stream=None,
debug=0, wrap=60, metal=1, tal=1, showtal=-1):
debug=0, wrap=60, metal=1, tal=1, showtal=-1,
strictinsert=1):
self.program = program
self.macros = macros
self.engine = engine
......@@ -164,6 +165,7 @@ class TALInterpreter:
if showtal == -1:
showtal = (not tal)
self.showtal = showtal
self.strictinsert = strictinsert
self.html = 0
self.slots = {}
self.currentMacro = None
......@@ -321,6 +323,10 @@ class TALInterpreter:
if structure is None:
return
text = str(structure)
if not repldict and not self.strictinsert:
# Take a shortcut, no error checking
self.stream_write(text)
return
if self.html:
self.insertHTMLStructure(text, repldict)
else:
......
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