[ZPT] CVS: Packages/TAL - TALInterpreter.py:1.33

guido@digicool.com guido@digicool.com
Mon, 9 Apr 2001 11:27:30 -0400 (EDT)


Update of /cvs-repository/Packages/TAL
In directory korak:/tmp/cvs-serv25722

Modified Files:
	TALInterpreter.py 
Log Message:
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. :-)



--- Updated File TALInterpreter.py in package Packages/TAL --
--- TALInterpreter.py	2001/04/07 19:25:03	1.32
+++ TALInterpreter.py	2001/04/09 15:27:29	1.33
@@ -150,7 +150,8 @@
 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 @@
         if showtal == -1:
             showtal = (not tal)
         self.showtal = showtal
+        self.strictinsert = strictinsert
         self.html = 0
         self.slots = {}
         self.currentMacro = None
@@ -321,6 +323,10 @@
         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: