Commit e696ec1a authored by Evan Simpson's avatar Evan Simpson

Fix Collector #372

parent eaa213c1
...@@ -28,6 +28,8 @@ Zope Changes ...@@ -28,6 +28,8 @@ Zope Changes
Bugs Fixed Bugs Fixed
- Collector #372: tal:attributes failed when combined with tal:replace.
- Don't try to close network connections in the signal handler - Don't try to close network connections in the signal handler
for shutdown. This hosed ZEO clients. for shutdown. This hosed ZEO clients.
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
"""Generic Python Expression Handler """Generic Python Expression Handler
""" """
__version__='$Revision: 1.10 $'[11:-2] __version__='$Revision: 1.11 $'[11:-2]
from TALES import CompilerError from TALES import CompilerError
from sys import exc_info from sys import exc_info
...@@ -47,7 +47,7 @@ class PythonExpr: ...@@ -47,7 +47,7 @@ class PythonExpr:
# Bind template variables # Bind template variables
names = {} names = {}
vars = econtext.vars vars = econtext.vars
getType = econtext._engine.getTypes().get getType = econtext.getCompiler().getTypes().get
for vname in self._f_varnames: for vname in self._f_varnames:
val = vars.get(vname, _marker) val = vars.get(vname, _marker)
if val is _marker: if val is _marker:
...@@ -78,5 +78,5 @@ class ExprTypeProxy: ...@@ -78,5 +78,5 @@ class ExprTypeProxy:
self._econtext = econtext self._econtext = econtext
def __call__(self, text): def __call__(self, text):
return self._handler(self._name, text, return self._handler(self._name, text,
self._econtext._engine)(self._econtext) self._econtext.getCompiler())(self._econtext)
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
An implementation of a generic TALES engine An implementation of a generic TALES engine
""" """
__version__='$Revision: 1.35 $'[11:-2] __version__='$Revision: 1.36 $'[11:-2]
import re, sys, ZTUtils import re, sys, ZTUtils
from MultiMapping import MultiMapping from MultiMapping import MultiMapping
...@@ -152,8 +152,8 @@ class Context: ...@@ -152,8 +152,8 @@ class Context:
position = (None, None) position = (None, None)
source_file = None source_file = None
def __init__(self, engine, contexts): def __init__(self, compiler, contexts):
self._engine = engine self._compiler = compiler
self.contexts = contexts self.contexts = contexts
contexts['nothing'] = None contexts['nothing'] = None
contexts['default'] = Default contexts['default'] = Default
...@@ -170,6 +170,9 @@ class Context: ...@@ -170,6 +170,9 @@ class Context:
# Keep track of what needs to be popped as each scope ends. # Keep track of what needs to be popped as each scope ends.
self._scope_stack = [] self._scope_stack = []
def getCompiler(self):
return self._compiler
def beginScope(self): def beginScope(self):
self._scope_stack.append([self.local_vars.copy()]) self._scope_stack.append([self.local_vars.copy()])
...@@ -198,8 +201,8 @@ class Context: ...@@ -198,8 +201,8 @@ class Context:
def setRepeat(self, name, expr): def setRepeat(self, name, expr):
expr = self.evaluate(expr) expr = self.evaluate(expr)
if not expr: if not expr:
return self._engine.Iterator(name, (), self) return self._compiler.Iterator(name, (), self)
it = self._engine.Iterator(name, expr, self) it = self._compiler.Iterator(name, expr, self)
old_value = self.repeat_vars.get(name) old_value = self.repeat_vars.get(name)
self._scope_stack[-1].append((name, old_value)) self._scope_stack[-1].append((name, old_value))
self.repeat_vars[name] = it self.repeat_vars[name] = it
...@@ -208,7 +211,7 @@ class Context: ...@@ -208,7 +211,7 @@ class Context:
def evaluate(self, expression, def evaluate(self, expression,
isinstance=isinstance, StringType=StringType): isinstance=isinstance, StringType=StringType):
if isinstance(expression, StringType): if isinstance(expression, StringType):
expression = self._engine.compile(expression) expression = self._compiler.compile(expression)
__traceback_supplement__ = ( __traceback_supplement__ = (
TALESTracebackSupplement, self, expression) TALESTracebackSupplement, self, expression)
return expression(self) return expression(self)
......
...@@ -62,6 +62,9 @@ class DummyEngine: ...@@ -62,6 +62,9 @@ class DummyEngine:
def getCompilerError(self): def getCompilerError(self):
return CompilerError return CompilerError
def getCompiler(self):
return self
def setSourceFile(self, source_file): def setSourceFile(self, source_file):
self.source_file = source_file self.source_file = source_file
......
...@@ -41,6 +41,9 @@ class ITALESEngine(Interface): ...@@ -41,6 +41,9 @@ class ITALESEngine(Interface):
ITALESCompiler.compile(). ITALESCompiler.compile().
""" """
def getCompiler():
"""Return an object that supports ITALESCompiler."""
def getDefault(): def getDefault():
"""Return the value of the 'default' TALES expression. """Return the value of the 'default' TALES expression.
......
...@@ -594,7 +594,7 @@ class TALInterpreter: ...@@ -594,7 +594,7 @@ class TALInterpreter:
def insertHTMLStructure(self, text, repldict): def insertHTMLStructure(self, text, repldict):
from HTMLTALParser import HTMLTALParser from HTMLTALParser import HTMLTALParser
gen = AltTALGenerator(repldict, self.engine, 0) gen = AltTALGenerator(repldict, self.engine.getCompiler(), 0)
p = HTMLTALParser(gen) # Raises an exception if text is invalid p = HTMLTALParser(gen) # Raises an exception if text is invalid
p.parseString(text) p.parseString(text)
program, macros = p.getCode() program, macros = p.getCode()
...@@ -602,7 +602,7 @@ class TALInterpreter: ...@@ -602,7 +602,7 @@ class TALInterpreter:
def insertXMLStructure(self, text, repldict): def insertXMLStructure(self, text, repldict):
from TALParser import TALParser from TALParser import TALParser
gen = AltTALGenerator(repldict, self.engine, 0) gen = AltTALGenerator(repldict, self.engine.getCompiler(), 0)
p = TALParser(gen) p = TALParser(gen)
gen.enable(0) gen.enable(0)
p.parseFragment('<!DOCTYPE foo PUBLIC "foo" "bar"><foo>') p.parseFragment('<!DOCTYPE foo PUBLIC "foo" "bar"><foo>')
......
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