This template fails on Zope 2.13.13 (which uses zope.tal-3.5.2 at this moment):
<html>
<head>
<title tal:content="template/title">The title</title>
</head>
<body>
<div tal:attributes="attr0 string: value0" tal:replace="structure string: WTF?" />
</body>
</html>
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/lib/python2.7/site-packages/Zope2-2.13.13-py2.7.egg/Shared/DC/Scripts/Bindings.py", line 322, in __call__
return self._bindAndExec(args, kw, None)
File "/data/lib/python2.7/site-packages/Zope2-2.13.13-py2.7.egg/Shared/DC/Scripts/Bindings.py", line 359, in _bindAndExec
return self._exec(bound_data, args, kw)
File "/data/lib/python2.7/site-packages/Zope2-2.13.13-py2.7.egg/Products/PageTemplates/ZopePageTemplate.py", line 334, in _exec
result = self.pt_render(extra_context=bound_names)
File "/data/lib/python2.7/site-packages/Zope2-2.13.13-py2.7.egg/Products/PageTemplates/ZopePageTemplate.py", line 431, in pt_render
result = PageTemplate.pt_render(self, source, extra_context)
File "/data/lib/python2.7/site-packages/Zope2-2.13.13-py2.7.egg/Products/PageTemplates/PageTemplate.py", line 79, in pt_render
showtal=showtal)
File "/data/lib/python2.7/site-packages/zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py", line 113, in pt_render
strictinsert=0, sourceAnnotations=sourceAnnotations)()
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 271, in __call__
self.interpret(self.program)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 531, in do_optTag_tal
self.no_tag(stuff[-2], stuff[-1])
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 513, in no_tag
self.interpret(program)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 343, in interpret
handlers[opcode](self, args)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 757, in do_insertStructure_tal
self.insertHTMLStructure(text, repldict)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 781, in insertHTMLStructure
gen = AltTALGenerator(repldict, self.engine, 0)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talinterpreter.py", line 65, in __init__
TALGenerator.__init__(self, expressionCompiler, xml)
File "/data/lib/python2.7/site-packages/zope.tal-3.5.2-py2.7.egg/zope/tal/talgenerator.py", line 41, in __init__
self.CompilerError = expressionCompiler.getCompilerError()
AttributeError: 'ZopeContext' object has no attribute 'getCompilerError'
TALGenerator.__init__() expects to have in its expressionCompiler parameter an zope.tal.interfaces.ITALExpressionCompiler instance that has getCompilerError() method.
Instead of that zope.pagetemplate.pagetemplate.PageTemplate.pt_render() passes down along the chain an instance of Products.PageTemplates.Expressions.ZopeContext class, which implements ITALExpressionEngine. From zope.pagetemplate-3.5.2-py2.7.egg/zope/pagetemplate/pagetemplate.py:110
context = self.pt_getEngineContext(namespace)
TALInterpreter(self._v_program, self._v_macros,
context, output, tal=not source, showtal=showtal,
strictinsert=0, sourceAnnotations=sourceAnnotations)()
pdb.pm():
(Pdb) from zope.tal.interfaces import ITALExpressionCompiler, ITALExpressionEngine
(Pdb) expressionCompiler
<Products.PageTemplates.Expressions.ZopeContext object at 0xaea0b62c>
(Pdb) ITALExpressionCompiler.implementedBy(expressionCompiler.__class__)
False
(Pdb) ITALExpressionEngine.implementedBy(expressionCompiler.__class__)
True
(Pdb) expressionCompiler._engine
<Products.PageTemplates.Expressions.ZopeEngine object at 0xb702e54c>
(Pdb) ITALExpressionCompiler.implementedBy(expressionCompiler._engine.__class__)
True
(Pdb) expressionCompiler._engine.getCompilerError()
<class 'zope.tales.tales.CompilerError'>
Without this /very useful/ combination of "tal:attribuites", "tal:replace" and "structure" interpretation goes into another branch of zope.tal.interpreter.do_insertStructure_tal(), that doesn't use TALGenerator and hence doesn't fail. I thank our bright developers for revealing this.
Regards,
Evgeny
As a workaround try to remove the tal:attributes. Since tal:replace will replace the entire tag, the attributes call is a bit useless. But http:// pagetemplates. org/docs/ latest/ reference. html#tal- attributes says the attributes should be ignored and is apparently valid syntax.