Commit e696ec1a authored by Evan Simpson's avatar Evan Simpson

Fix Collector #372

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