Cope with TAL 1.6 bytecode changes:

* tal:replace now emits something different (optTag)
* constructs with i18n:name emits more complicated bytecode (i18nVariable, etc.)
  to cope with behavioural changes (see http://zope.org/Collectors/Zope3-dev/301)
* probably some more that aren't very interesting (if these any of this is
  interesting at all)
parent d7af83a8
......@@ -345,9 +345,13 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='string:foo'>bar</p>", [
('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'string:foo'}),
('insertText', ('$string:foo$',
[('startTag', ('p', [('tal:replace', 'string:foo', 'tal')])),
rawtext('bar</p>')])),
('optTag',
('p',
'',
None,
0,
[('startTag', ('p', [('tal:replace', 'string:foo', 'tal')]))],
[('insertText', ('$string:foo$', [rawtext('bar')]))])),
('endScope', ()),
])
......@@ -355,10 +359,13 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='text string:foo'>bar</p>", [
('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'text string:foo'}),
('insertText', ('$string:foo$',
[('startTag', ('p',
[('tal:replace', 'text string:foo', 'tal')])),
rawtext('bar</p>')])),
('optTag',
('p',
'',
None,
0,
[('startTag', ('p', [('tal:replace', 'text string:foo', 'tal')]))],
[('insertText', ('$string:foo$', [('rawtextOffset', ('bar', 3))]))])),
('endScope', ()),
])
......@@ -366,10 +373,14 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'structure string:<br>'}),
('insertStructure', ('$string:<br>$', {},
[('startTag', ('p',
[('tal:replace', 'structure string:<br>', 'tal')])),
rawtext('bar</p>')])),
('optTag',
('p',
'',
None,
0,
[('startTag', ('p', [('tal:replace', 'structure string:<br>', 'tal')]))],
[('insertStructure',
('$string:<br>$', {}, [('rawtextOffset', ('bar', 3))]))])),
('endScope', ()),
])
......@@ -383,9 +394,13 @@ class TALGeneratorTestCases(TestCaseBase):
[('tal:repeat', 'x python:(1,2,3)', 'tal')])),
('setPosition', (1, 33)),
('beginScope', {'tal:replace': 'x'}),
('insertText', ('$x$',
[('startTag', ('span', [('tal:replace', 'x', 'tal')])),
rawtext('dummy</span>')])),
('optTag',
('span',
'',
None,
0,
[('startTag', ('span', [('tal:replace', 'x', 'tal')]))],
[('insertText', ('$x$', [rawtext('dummy')]))])),
('endScope', ()),
rawtext('</p>')])),
('endScope', ()),
......@@ -416,14 +431,19 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',
{'tal:attributes': 'src string:foo.png',
'tal:replace': 'structure string:<img>'}),
('insertStructure',
('$string:<img>$',
{'src': ('$string:foo.png$', 0, None)},
[('startTag', ('p',
('optTag',
('p',
'',
None,
0,
[('startTag',
('p',
[('tal:replace', 'structure string:<img>', 'tal'),
('tal:attributes', 'src string:foo.png',
'tal')])),
rawtext('duh</p>')])),
('tal:attributes', 'src string:foo.png', 'tal')]))],
[('insertStructure',
('$string:<img>$',
{'src': ('$string:foo.png$', False, None)},
[rawtext('duh')]))])),
('endScope', ()),
])
......@@ -454,11 +474,16 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope',
{'tal:replace': 'notHere', 'tal:on-error': 'string:error'}),
('onError',
([('insertText', ('$notHere$',
[('startTag', ('p',
([('optTag',
('p',
'',
None,
0,
[('startTag',
('p',
[('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')])),
rawtext('okay</p>')]))],
('tal:replace', 'notHere', 'tal')]))],
[('insertText', ('$notHere$', [('rawtextOffset', ('okay', 4))]))]))],
[('startTag', ('p',
[('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')])),
......@@ -560,10 +585,14 @@ translated string</span>
[('rawtextOffset', ('replaceable ', 12)),
('setPosition', (1, 36)),
('beginScope', {'tal:replace': 'str:here'}),
('insertText',
('$str:here$',
[('startTag', ('p', [('tal:replace', 'str:here', 'tal')])),
('rawtextOffset', ('content</p>', 11))])),
('optTag',
('p',
'',
None,
0,
[('startTag', ('p', [('tal:replace', 'str:here', 'tal')]))],
[('insertText',
('$str:here$', [rawtext('content')]))])),
('endScope', ())])),
('endScope', ()),
('rawtextColumn', ('</span>\n', 0))
......@@ -590,12 +619,18 @@ translated string</span>
{'i18n:name': 'name', 'tal:replace': 'str:Lomax'})),
('i18nVariable',
('name',
[('optTag',
('span',
'',
None,
1,
[('startEndTag',
('span',
[('tal:replace', 'str:Lomax', 'tal'),
('i18n:name', 'name', 'i18n')]))],
'$str:Lomax$',
0)),
[('insertText', ('$str:Lomax$', []))]))],
None,
False)),
('rawtextBeginScope',
(' was born in\n ',
2,
......@@ -604,12 +639,18 @@ translated string</span>
{'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})),
('i18nVariable',
('country',
[('optTag',
('span',
'',
None,
1,
[('startEndTag',
('span',
[('tal:replace', 'str:Antarctica', 'tal'),
('i18n:name', 'country', 'i18n')]))],
'$str:Antarctica$',
0)),
[('insertText', ('$str:Antarctica$', []))]))],
None,
False)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
......@@ -665,12 +706,20 @@ translated string</span>
[('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})),
('i18nVariable',
('name',
[('rawtextOffset', ('<b>Jim</b>', 10))], None, 0)),
[('startTag', ('span', [('i18n:name', 'name', 'i18n')])),
('rawtextOffset', ('<b>Jim</b>', 10)),
('rawtextOffset', ('</span>', 7))],
None,
False)),
('rawtextBeginScope',
(' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country'})),
('i18nVariable',
('country',
[('rawtextOffset', ('the USA', 7))], None, 0)),
[('startTag', ('span', [('i18n:name', 'country', 'i18n')])),
('rawtextOffset', ('the USA', 7)),
('rawtextOffset', ('</span>', 7))],
None,
False)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
......@@ -778,15 +827,20 @@ translated string</span>
{'i18n:data': 'here/currentTime',
'i18n:name': 'time',
'i18n:translate': 'timefmt'})),
('insertTranslation',
('timefmt',
('i18nVariable',
('time',
[('startTag',
('span',
[('i18n:data', 'here/currentTime', 'i18n'),
('i18n:translate', 'timefmt', 'i18n'),
('i18n:name', 'time', 'i18n')])),
('i18nVariable', ('time', [], None, 0))],
('insertTranslation',
('timefmt',
[('rawtextOffset', ('2:32 pm', 7))],
'$here/currentTime$')),
('rawtextOffset', ('</span>', 7))],
None,
False)),
('endScope', ()),
('rawtextOffset', ('... beep!', 9))])),
('endScope', ()),
......@@ -813,14 +867,20 @@ translated string</span>
{'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})),
('i18nVariable',
('jobnum',
[('optTag',
('span',
'',
None,
0,
[('startTag',
('span',
[('tal:replace', 'context/@@object_name', 'tal'),
('i18n:name', 'jobnum', 'i18n')])),
('rawtextOffset', ('NN', 2)),
('rawtextOffset', ('</span>', 7))],
'$context/@@object_name$',
0)),
('i18n:name', 'jobnum', 'i18n')]))],
[('insertText',
('$context/@@object_name$',
[('rawtextOffset', ('NN', 2))]))]))],
None,
False)),
('endScope', ())])),
('endScope', ()),
('rawtextColumn', ('</span>\n', 0))
......@@ -848,7 +908,8 @@ translated string</span>
{'i18n:name': 'email'})),
('i18nVariable',
('email',
[('rawtextBeginScope',
[('startTag', ('span', [('i18n:name', 'email', 'i18n')])),
('rawtextBeginScope',
('\n ',
4,
(3, 4),
......@@ -863,14 +924,14 @@ translated string</span>
('$request/submitter$',
[('rawtextOffset', ('user@host.com', 13))])),
('endScope', ()),
('rawtextOffset', ('</a>', 4))],
('rawtextOffset', ('</a>', 4)),
('rawtextOffset', ('</span>', 7))],
None,
0)),
False)),
('endScope', ()),
('rawtextColumn', ('\n', 0))])),
('endScope', ()),
('rawtextColumn', ('</p>\n', 0))
])
('rawtextColumn', ('</p>\n', 0))])
def check_i18n_name_with_tal_content(self):
# input/test27.html
......
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