Commit a53e7d3f authored by Evan Simpson's avatar Evan Simpson

Fix Collector #539, and make DummyEngine work outside of Zope.

parent c1624616
......@@ -6,6 +6,9 @@ Zope Changes
Bugs Fixed
- Collector #539: Fixed rendering of TAL namespace tags with an
'on-error' statement.
- Collector #586: Generated 'start' scripts had a nonsensical
export of an "INST_HOME" environment variable.
......
<html>
<body>
<head>
<title tal:content="string:Hello World!">This is the title</title>
</head>
<body>
<tal:block on-error="string:Error:${error/value}" replace="x" />
<tal:block on-error="string:Error:${error/value}">
<p tal:content="x">p</p>
</tal:block>
<div tal:replace="structure string:&lt;hr /&gt;">rule</div>
</body>
</html>
<html>
<body>
<head>
<title>Hello World!</title>
</head>
<body>
Error:x
Error:x
<hr />
</body>
</html>
......@@ -21,11 +21,16 @@ import sys
from TALDefs import NAME_RE, TALESError, ErrorInfo
from ITALES import ITALESCompiler, ITALESEngine
from DocumentTemplate.DT_Util import ustr
try:
IDomain = None
if sys.modules.has_key('Zope'):
try:
from Zope.I18n.ITranslationService import ITranslationService
from Zope.I18n.IDomain import IDomain
except ImportError:
# Before 2.7
except ImportError:
pass
if IDomain is None:
# Before 2.7, or not in Zope
class ITranslationService: pass
class IDomain: pass
......
......@@ -275,7 +275,7 @@ class TALGenerator:
else:
self.emit("setGlobal", name, cexpr)
def emitOnError(self, name, onError):
def emitOnError(self, name, onError, TALtag, isend):
block = self.popProgram()
key, expr = parseSubstitution(onError)
cexpr = self.compileExpression(expr)
......@@ -284,6 +284,9 @@ class TALGenerator:
else:
assert key == "structure"
self.emit("insertStructure", cexpr, {}, [])
if TALtag:
self.emitOptTag(name, (None, 1), isend)
else:
self.emitEndTag(name)
handler = self.popProgram()
self.emit("onError", block, handler)
......@@ -599,7 +602,11 @@ class TALGenerator:
todo["scope"] = 1
if onError:
self.pushProgram() # handler
if TALtag:
self.pushProgram() # start
self.emitStartTag(name, list(attrlist)) # Must copy attrlist!
if TALtag:
self.pushProgram() # start
self.pushProgram() # block
todo["onError"] = onError
if define:
......@@ -758,7 +765,7 @@ class TALGenerator:
if condition:
self.emitCondition(condition)
if onError:
self.emitOnError(name, onError)
self.emitOnError(name, onError, optTag and optTag[1], isend)
if scope:
self.emit("endScope")
if i18ncontext:
......
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