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