Commit 82841082 authored by Evan Simpson's avatar Evan Simpson

Change CancelAction to Default and eliminate inserted attribute turds.

parent e13dcef9
......@@ -92,7 +92,7 @@ import string
from TALDefs import NAME_RE, TALError, TALESError
CancelAction = []
Default = []
class DummyEngine:
......@@ -122,12 +122,10 @@ class DummyEngine:
if self.locals is self.stack[-1]:
# Unmerge this scope's locals from previous scope of first set
self.locals = self.locals.copy()
if value is not CancelAction:
self.locals[name] = value
def setGlobal(self, name, value):
if value is not CancelAction:
self.globals[name] = value
self.globals[name] = value
def evaluate(self, expression):
expression = self.uncompile(expression)
......@@ -225,8 +223,8 @@ class DummyEngine:
def getTALESError(self):
return TALESError
def getCancelAction(self):
return CancelAction
def getDefault(self):
return Default
class Iterator:
......
......@@ -157,7 +157,7 @@ class TALInterpreter:
self.macros = macros
self.engine = engine
self.TALESError = engine.getTALESError()
self.CancelAction = engine.getCancelAction()
self.Default = engine.getDefault()
self.stream = stream or sys.stdout
self.debug = debug
self.wrap = wrap
......@@ -265,7 +265,7 @@ class TALInterpreter:
if action <= 1 and self.tal:
if self.html and string.lower(name) in BOOLEAN_HTML_ATTRS:
evalue = self.engine.evaluateBoolean(item[3])
if evalue is self.CancelAction:
if evalue is self.Default:
if action == 1: # Cancelled insert
continue
elif not evalue:
......@@ -274,7 +274,7 @@ class TALInterpreter:
value = None
else:
evalue = self.engine.evaluateText(item[3])
if evalue is self.CancelAction:
if evalue is self.Default:
if action == 1: # Cancelled insert
continue
else:
......@@ -285,6 +285,8 @@ class TALInterpreter:
name[-13:] == ":define-macro" and self.metal):
name = name[:-13] + ":use-macro"
value = self.currentMacro
elif action == 1:
continue # Unexecuted insert
if value is None:
s = name
else:
......@@ -327,7 +329,7 @@ class TALInterpreter:
text = self.engine.evaluateText(expr)
if text is None:
return
if text is self.CancelAction:
if text is self.Default:
self.interpret(block)
return
text = cgi.escape(text)
......@@ -340,7 +342,7 @@ class TALInterpreter:
structure = self.engine.evaluateStructure(expr)
if structure is None:
return
if structure is self.CancelAction:
if structure is self.Default:
self.interpret(block)
return
text = str(structure)
......@@ -397,7 +399,7 @@ class TALInterpreter:
self.interpret(block)
return
macro = self.engine.evaluateMacro(macroExpr)
if macro is self.CancelAction:
if macro is self.Default:
self.interpret(block)
return
if not isCurrentVersion(macro):
......
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