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