[Zope3-checkins] SVN: Zope3/trunk/src/zope/tal/t Fix for issue 233
in the Zope 3 collector.
Fred L. Drake, Jr.
fred at zope.com
Tue Jul 13 15:19:55 EDT 2004
Log message for revision 26508:
Fix for issue 233 in the Zope 3 collector.
This corresponds to the Hotfix_2004-07-13 product.
(Merged from ZopeX3-3.0 branch revision 26504.)
Changed:
U Zope3/trunk/src/zope/tal/taldefs.py
U Zope3/trunk/src/zope/tal/talgenerator.py
U Zope3/trunk/src/zope/tal/talinterpreter.py
A Zope3/trunk/src/zope/tal/tests/input/test36.html
A Zope3/trunk/src/zope/tal/tests/output/test36.html
U Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py
U Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
-=-
Modified: Zope3/trunk/src/zope/tal/taldefs.py
===================================================================
--- Zope3/trunk/src/zope/tal/taldefs.py 2004-07-13 19:19:44 UTC (rev 26507)
+++ Zope3/trunk/src/zope/tal/taldefs.py 2004-07-13 19:19:55 UTC (rev 26508)
@@ -19,7 +19,7 @@
from zope.tal.interfaces import ITALExpressionErrorInfo
from zope.interface import implements
-TAL_VERSION = "1.4"
+TAL_VERSION = "1.5"
XML_NS = "http://www.w3.org/XML/1998/namespace" # URI for XML namespace
XMLNS_NS = "http://www.w3.org/2000/xmlns/" # URI for XML NS declarations
Modified: Zope3/trunk/src/zope/tal/talgenerator.py
===================================================================
--- Zope3/trunk/src/zope/tal/talgenerator.py 2004-07-13 19:19:44 UTC (rev 26507)
+++ Zope3/trunk/src/zope/tal/talgenerator.py 2004-07-13 19:19:55 UTC (rev 26508)
@@ -339,7 +339,7 @@
m = _name_rx.match(varname)
if m is None or m.group() != varname:
raise TALError("illegal i18n:name: %r" % varname, self.position)
- cexpr = None
+ key = cexpr = None
program = self.popProgram()
if action == I18N_REPLACE:
# This is a tag with an i18n:name and a tal:replace (implicit or
@@ -355,7 +355,8 @@
assert action == I18N_EXPRESSION
key, expr = parseSubstitution(expression)
cexpr = self.compileExpression(expr)
- self.emit('i18nVariable', varname, program, cexpr)
+ self.emit('i18nVariable',
+ varname, program, cexpr, int(key == "structure"))
def emitTranslation(self, msgid, i18ndata):
program = self.popProgram()
@@ -797,7 +798,8 @@
# - I18N_CONTENT for tal:content
# - I18N_EXPRESSION for explicit tal:replace
# o varname[2] will be None for the first two actions and the
- # replacement tal expression for the third action.
+ # replacement tal expression for the third action. This
+ # can include a 'text' or 'structure' indicator.
assert (varname[1]
in [I18N_REPLACE, I18N_CONTENT, I18N_EXPRESSION])
self.emitI18nVariable(varname)
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py 2004-07-13 19:19:44 UTC (rev 26507)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py 2004-07-13 19:19:55 UTC (rev 26508)
@@ -15,6 +15,7 @@
$Id$
"""
+import cgi
import sys
# Do not use cStringIO here! It's not unicode aware. :(
@@ -575,7 +576,7 @@
bytecode_handlers["insertText"] = do_insertText
def do_i18nVariable(self, stuff):
- varname, program, expression = stuff
+ varname, program, expression, structure = stuff
if expression is None:
# The value is implicitly the contents of this tag, so we have to
# evaluate the mini-program to get the value of the variable.
@@ -593,13 +594,19 @@
else:
# Evaluate the value to be associated with the variable in the
# i18n interpolation dictionary.
- value = self.engine.evaluate(expression)
+ if structure:
+ value = self.engine.evaluateStructure(expression)
+ else:
+ value = self.engine.evaluate(expression)
# evaluate() does not do any I18n, so we do it here.
if isinstance(value, MessageID):
# Translate this now.
value = self.engine.translate(value)
+ if not structure:
+ value = cgi.escape(str(value))
+
# Either the i18n:name tag is nested inside an i18n:translate in which
# case the last item on the stack has the i18n dictionary and string
# representation, or the i18n:name and i18n:translate attributes are
Copied: Zope3/trunk/src/zope/tal/tests/input/test36.html (from rev 26504, Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/input/test36.html)
Copied: Zope3/trunk/src/zope/tal/tests/output/test36.html (from rev 26504, Zope3/branches/ZopeX3-3.0/src/zope/tal/tests/output/test36.html)
Modified: Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py 2004-07-13 19:19:44 UTC (rev 26507)
+++ Zope3/trunk/src/zope/tal/tests/test_htmltalparser.py 2004-07-13 19:19:55 UTC (rev 26508)
@@ -635,7 +635,8 @@
('span',
[('tal:replace', 'str:Lomax', 'tal'),
('i18n:name', 'name', 'i18n')]))],
- '$str:Lomax$')),
+ '$str:Lomax$',
+ 0)),
('rawtextBeginScope',
(' was born in\n ',
2,
@@ -648,7 +649,8 @@
('span',
[('tal:replace', 'str:Antarctica', 'tal'),
('i18n:name', 'country', 'i18n')]))],
- '$str:Antarctica$')),
+ '$str:Antarctica$',
+ 0)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
@@ -679,7 +681,8 @@
('',
[('insertText', ('$bar$', []))])),
('rawtextOffset', ('</span>', 7))],
- None)),
+ None,
+ 0)),
('endScope', ()),
('rawtextOffset', ('.', 1))])),
('endScope', ()),
@@ -702,12 +705,12 @@
[('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})),
('i18nVariable',
('name',
- [('rawtextOffset', ('<b>Jim</b>', 10))], None)),
+ [('rawtextOffset', ('<b>Jim</b>', 10))], None, 0)),
('rawtextBeginScope',
(' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country'})),
('i18nVariable',
('country',
- [('rawtextOffset', ('the USA', 7))], None)),
+ [('rawtextOffset', ('the USA', 7))], None, 0)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
@@ -822,7 +825,7 @@
[('i18n:data', 'here/currentTime', 'i18n'),
('i18n:translate', 'timefmt', 'i18n'),
('i18n:name', 'time', 'i18n')])),
- ('i18nVariable', ('time', [], None))],
+ ('i18nVariable', ('time', [], None, 0))],
'$here/currentTime$')),
('endScope', ()),
('rawtextOffset', ('... beep!', 9))])),
@@ -857,7 +860,8 @@
('i18n:name', 'jobnum', 'i18n')])),
('rawtextOffset', ('NN', 2)),
('rawtextOffset', ('</span>', 7))],
- '$context/@@object_name$')),
+ '$context/@@object_name$',
+ 0)),
('endScope', ())])),
('endScope', ()),
('rawtextColumn', ('</span>\n', 0))
@@ -901,7 +905,8 @@
[('rawtextOffset', ('user at host.com', 13))])),
('endScope', ()),
('rawtextOffset', ('</a>', 4))],
- None)),
+ None,
+ 0)),
('endScope', ()),
('rawtextColumn', ('\n', 0))])),
('endScope', ()),
@@ -941,7 +946,8 @@
('$request/submitter$',
[('rawtextOffset', ('user at host.com', 13))])),
('rawtextOffset', ('</a>', 4))],
- None)),
+ None,
+ 0)),
('endScope', ()),
('rawtextColumn', ('\n', 0))])),
('endScope', ()),
Modified: Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2004-07-13 19:19:44 UTC (rev 26507)
+++ Zope3/trunk/src/zope/tal/tests/test_talinterpreter.py 2004-07-13 19:19:55 UTC (rev 26508)
@@ -155,7 +155,7 @@
'<div>THIS IS TEXT FOR <span>BARVALUE</span>.</div>\n')
def test_translate_static_text_as_dynamic_from_bytecode(self):
- program = [('version', '1.4'),
+ program = [('version', '1.5'),
('mode', 'html'),
('setPosition', (1, 0)),
('beginScope', {'i18n:translate': ''}),
@@ -177,7 +177,8 @@
('',
[('insertText', ('$bar$', []))])),
('rawtextOffset', ('</span>', 7))],
- None)),
+ None,
+ 0)),
('endScope', ()),
('rawtextOffset', ('.', 1))])),
('endScope', ()),
More information about the Zope3-Checkins
mailing list