Last active
August 29, 2015 14:11
-
-
Save autumnjolitz/6070af860e21a8a50771 to your computer and use it in GitHub Desktop.
Zope2.11+ has a problem as the TALInterpreter expects an ITALExpressionCompiler but instead got passed the ZopeContext (which has such INSIDE IT as _engine)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/python/zope/tal/talgenerator.py b/lib/python/zope/tal/talgenerator.py | |
index cf2c440..9dc37e8 100644 | |
--- a/lib/python/zope/tal/talgenerator.py | |
+++ b/lib/python/zope/tal/talgenerator.py | |
@@ -23,12 +23,13 @@ from zope.tal.taldefs import NAME_RE, TAL_VERSION | |
from zope.tal.taldefs import I18NError, METALError, TALError | |
from zope.tal.taldefs import parseSubstitution | |
from zope.tal.translationcontext import TranslationContext, DEFAULT_DOMAIN | |
+from zope.tal.interfaces import ITALExpressionCompiler | |
_name_rx = re.compile(NAME_RE) | |
-class TALGenerator(object): | |
+class TALGenerator(object): | |
inMacroUse = 0 | |
inMacroDef = 0 | |
source_file = None | |
@@ -37,6 +38,14 @@ class TALGenerator(object): | |
if not expressionCompiler: | |
from zope.tal.dummyengine import DummyEngine | |
expressionCompiler = DummyEngine() | |
+ | |
+ if expressionCompiler and not \ | |
+ ITALExpressionCompiler.providedBy(expressionCompiler): | |
+ raise TypeError( | |
+ ('expressionCompiler for %s is NOT an ITALExpressionCompiler.' | |
+ 'Type is %s') % | |
+ ((str(self.__class__)), str(type(expressionCompiler)))) | |
+ | |
self.expressionCompiler = expressionCompiler | |
self.CompilerError = expressionCompiler.getCompilerError() | |
# This holds the emitted opcodes representing the input | |
diff --git a/lib/python/zope/tal/talinterpreter.py b/lib/python/zope/tal/talinterpreter.py | |
index 9e65be5..d725307 100644 | |
--- a/lib/python/zope/tal/talinterpreter.py | |
+++ b/lib/python/zope/tal/talinterpreter.py | |
@@ -30,7 +30,6 @@ from zope.tal.taldefs import getProgramVersion, getProgramMode | |
from zope.tal.talgenerator import TALGenerator | |
from zope.tal.translationcontext import TranslationContext | |
- | |
# Avoid constructing this tuple over and over | |
I18nMessageTypes = (Message,) | |
@@ -781,7 +780,7 @@ class TALInterpreter(object): | |
def insertHTMLStructure(self, text, repldict): | |
from zope.tal.htmltalparser import HTMLTALParser | |
- gen = AltTALGenerator(repldict, self.engine, 0) | |
+ gen = AltTALGenerator(repldict, self.engine._engine, 0) | |
p = HTMLTALParser(gen) # Raises an exception if text is invalid | |
p.parseString(text) | |
program, macros = p.getCode() | |
@@ -789,7 +788,7 @@ class TALInterpreter(object): | |
def insertXMLStructure(self, text, repldict): | |
from zope.tal.talparser import TALParser | |
- gen = AltTALGenerator(repldict, self.engine, 0) | |
+ gen = AltTALGenerator(repldict, self.engine._engine, 0) | |
p = TALParser(gen) | |
gen.enable(0) | |
p.parseFragment('<!DOCTYPE foo PUBLIC "foo" "bar"><foo>') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment