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): ...@@ -345,9 +345,13 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='string:foo'>bar</p>", [ self._run_check("<p tal:replace='string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'string:foo'}), ('beginScope', {'tal:replace': 'string:foo'}),
('insertText', ('$string:foo$', ('optTag',
[('startTag', ('p', [('tal:replace', 'string:foo', 'tal')])), ('p',
rawtext('bar</p>')])), '',
None,
0,
[('startTag', ('p', [('tal:replace', 'string:foo', 'tal')]))],
[('insertText', ('$string:foo$', [rawtext('bar')]))])),
('endScope', ()), ('endScope', ()),
]) ])
...@@ -355,10 +359,13 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -355,10 +359,13 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='text string:foo'>bar</p>", [ self._run_check("<p tal:replace='text string:foo'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'text string:foo'}), ('beginScope', {'tal:replace': 'text string:foo'}),
('insertText', ('$string:foo$', ('optTag',
[('startTag', ('p', ('p',
[('tal:replace', 'text string:foo', 'tal')])), '',
rawtext('bar</p>')])), None,
0,
[('startTag', ('p', [('tal:replace', 'text string:foo', 'tal')]))],
[('insertText', ('$string:foo$', [('rawtextOffset', ('bar', 3))]))])),
('endScope', ()), ('endScope', ()),
]) ])
...@@ -366,10 +373,14 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -366,10 +373,14 @@ class TALGeneratorTestCases(TestCaseBase):
self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [ self._run_check("<p tal:replace='structure string:<br>'>bar</p>", [
('setPosition', (1, 0)), ('setPosition', (1, 0)),
('beginScope', {'tal:replace': 'structure string:<br>'}), ('beginScope', {'tal:replace': 'structure string:<br>'}),
('insertStructure', ('$string:<br>$', {}, ('optTag',
[('startTag', ('p', ('p',
[('tal:replace', 'structure string:<br>', 'tal')])), '',
rawtext('bar</p>')])), None,
0,
[('startTag', ('p', [('tal:replace', 'structure string:<br>', 'tal')]))],
[('insertStructure',
('$string:<br>$', {}, [('rawtextOffset', ('bar', 3))]))])),
('endScope', ()), ('endScope', ()),
]) ])
...@@ -383,9 +394,13 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -383,9 +394,13 @@ class TALGeneratorTestCases(TestCaseBase):
[('tal:repeat', 'x python:(1,2,3)', 'tal')])), [('tal:repeat', 'x python:(1,2,3)', 'tal')])),
('setPosition', (1, 33)), ('setPosition', (1, 33)),
('beginScope', {'tal:replace': 'x'}), ('beginScope', {'tal:replace': 'x'}),
('insertText', ('$x$', ('optTag',
[('startTag', ('span', [('tal:replace', 'x', 'tal')])), ('span',
rawtext('dummy</span>')])), '',
None,
0,
[('startTag', ('span', [('tal:replace', 'x', 'tal')]))],
[('insertText', ('$x$', [rawtext('dummy')]))])),
('endScope', ()), ('endScope', ()),
rawtext('</p>')])), rawtext('</p>')])),
('endScope', ()), ('endScope', ()),
...@@ -416,14 +431,19 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -416,14 +431,19 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope', ('beginScope',
{'tal:attributes': 'src string:foo.png', {'tal:attributes': 'src string:foo.png',
'tal:replace': 'structure string:<img>'}), 'tal:replace': 'structure string:<img>'}),
('insertStructure', ('optTag',
('$string:<img>$', ('p',
{'src': ('$string:foo.png$', 0, None)}, '',
[('startTag', ('p', None,
[('tal:replace', 'structure string:<img>', 'tal'), 0,
('tal:attributes', 'src string:foo.png', [('startTag',
'tal')])), ('p',
rawtext('duh</p>')])), [('tal:replace', 'structure string:<img>', 'tal'),
('tal:attributes', 'src string:foo.png', 'tal')]))],
[('insertStructure',
('$string:<img>$',
{'src': ('$string:foo.png$', False, None)},
[rawtext('duh')]))])),
('endScope', ()), ('endScope', ()),
]) ])
...@@ -454,11 +474,16 @@ class TALGeneratorTestCases(TestCaseBase): ...@@ -454,11 +474,16 @@ class TALGeneratorTestCases(TestCaseBase):
('beginScope', ('beginScope',
{'tal:replace': 'notHere', 'tal:on-error': 'string:error'}), {'tal:replace': 'notHere', 'tal:on-error': 'string:error'}),
('onError', ('onError',
([('insertText', ('$notHere$', ([('optTag',
[('startTag', ('p', ('p',
[('tal:on-error', 'string:error', 'tal'), '',
('tal:replace', 'notHere', 'tal')])), None,
rawtext('okay</p>')]))], 0,
[('startTag',
('p',
[('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')]))],
[('insertText', ('$notHere$', [('rawtextOffset', ('okay', 4))]))]))],
[('startTag', ('p', [('startTag', ('p',
[('tal:on-error', 'string:error', 'tal'), [('tal:on-error', 'string:error', 'tal'),
('tal:replace', 'notHere', 'tal')])), ('tal:replace', 'notHere', 'tal')])),
...@@ -560,10 +585,14 @@ translated string</span> ...@@ -560,10 +585,14 @@ translated string</span>
[('rawtextOffset', ('replaceable ', 12)), [('rawtextOffset', ('replaceable ', 12)),
('setPosition', (1, 36)), ('setPosition', (1, 36)),
('beginScope', {'tal:replace': 'str:here'}), ('beginScope', {'tal:replace': 'str:here'}),
('insertText', ('optTag',
('$str:here$', ('p',
[('startTag', ('p', [('tal:replace', 'str:here', 'tal')])), '',
('rawtextOffset', ('content</p>', 11))])), None,
0,
[('startTag', ('p', [('tal:replace', 'str:here', 'tal')]))],
[('insertText',
('$str:here$', [rawtext('content')]))])),
('endScope', ())])), ('endScope', ())])),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('</span>\n', 0)) ('rawtextColumn', ('</span>\n', 0))
...@@ -590,12 +619,18 @@ translated string</span> ...@@ -590,12 +619,18 @@ translated string</span>
{'i18n:name': 'name', 'tal:replace': 'str:Lomax'})), {'i18n:name': 'name', 'tal:replace': 'str:Lomax'})),
('i18nVariable', ('i18nVariable',
('name', ('name',
[('startEndTag', [('optTag',
('span', ('span',
[('tal:replace', 'str:Lomax', 'tal'), '',
('i18n:name', 'name', 'i18n')]))], None,
'$str:Lomax$', 1,
0)), [('startEndTag',
('span',
[('tal:replace', 'str:Lomax', 'tal'),
('i18n:name', 'name', 'i18n')]))],
[('insertText', ('$str:Lomax$', []))]))],
None,
False)),
('rawtextBeginScope', ('rawtextBeginScope',
(' was born in\n ', (' was born in\n ',
2, 2,
...@@ -604,12 +639,18 @@ translated string</span> ...@@ -604,12 +639,18 @@ translated string</span>
{'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})), {'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})),
('i18nVariable', ('i18nVariable',
('country', ('country',
[('startEndTag', [('optTag',
('span', ('span',
[('tal:replace', 'str:Antarctica', 'tal'), '',
('i18n:name', 'country', 'i18n')]))], None,
'$str:Antarctica$', 1,
0)), [('startEndTag',
('span',
[('tal:replace', 'str:Antarctica', 'tal'),
('i18n:name', 'country', 'i18n')]))],
[('insertText', ('$str:Antarctica$', []))]))],
None,
False)),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('.\n', 0))])), ('rawtextColumn', ('.\n', 0))])),
('endScope', ()), ('endScope', ()),
...@@ -664,13 +705,21 @@ translated string</span> ...@@ -664,13 +705,21 @@ translated string</span>
('', ('',
[('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})), [('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})),
('i18nVariable', ('i18nVariable',
('name', ('name',
[('rawtextOffset', ('<b>Jim</b>', 10))], None, 0)), [('startTag', ('span', [('i18n:name', 'name', 'i18n')])),
('rawtextBeginScope', ('rawtextOffset', ('<b>Jim</b>', 10)),
(' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country'})), ('rawtextOffset', ('</span>', 7))],
('i18nVariable', None,
('country', False)),
[('rawtextOffset', ('the USA', 7))], None, 0)), ('rawtextBeginScope',
(' was born in\n ', 2, (3, 2), 1, {'i18n:name': 'country'})),
('i18nVariable',
('country',
[('startTag', ('span', [('i18n:name', 'country', 'i18n')])),
('rawtextOffset', ('the USA', 7)),
('rawtextOffset', ('</span>', 7))],
None,
False)),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('.\n', 0))])), ('rawtextColumn', ('.\n', 0))])),
('endScope', ()), ('endScope', ()),
...@@ -778,15 +827,20 @@ translated string</span> ...@@ -778,15 +827,20 @@ translated string</span>
{'i18n:data': 'here/currentTime', {'i18n:data': 'here/currentTime',
'i18n:name': 'time', 'i18n:name': 'time',
'i18n:translate': 'timefmt'})), 'i18n:translate': 'timefmt'})),
('insertTranslation', ('i18nVariable',
('timefmt', ('time',
[('startTag', [('startTag',
('span', ('span',
[('i18n:data', 'here/currentTime', 'i18n'), [('i18n:data', 'here/currentTime', 'i18n'),
('i18n:translate', 'timefmt', 'i18n'), ('i18n:translate', 'timefmt', 'i18n'),
('i18n:name', 'time', 'i18n')])), ('i18n:name', 'time', 'i18n')])),
('i18nVariable', ('time', [], None, 0))], ('insertTranslation',
'$here/currentTime$')), ('timefmt',
[('rawtextOffset', ('2:32 pm', 7))],
'$here/currentTime$')),
('rawtextOffset', ('</span>', 7))],
None,
False)),
('endScope', ()), ('endScope', ()),
('rawtextOffset', ('... beep!', 9))])), ('rawtextOffset', ('... beep!', 9))])),
('endScope', ()), ('endScope', ()),
...@@ -813,14 +867,20 @@ translated string</span> ...@@ -813,14 +867,20 @@ translated string</span>
{'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})), {'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})),
('i18nVariable', ('i18nVariable',
('jobnum', ('jobnum',
[('startTag', [('optTag',
('span', ('span',
[('tal:replace', 'context/@@object_name', 'tal'), '',
('i18n:name', 'jobnum', 'i18n')])), None,
('rawtextOffset', ('NN', 2)), 0,
('rawtextOffset', ('</span>', 7))], [('startTag',
'$context/@@object_name$', ('span',
0)), [('tal:replace', 'context/@@object_name', 'tal'),
('i18n:name', 'jobnum', 'i18n')]))],
[('insertText',
('$context/@@object_name$',
[('rawtextOffset', ('NN', 2))]))]))],
None,
False)),
('endScope', ())])), ('endScope', ())])),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('</span>\n', 0)) ('rawtextColumn', ('</span>\n', 0))
...@@ -848,7 +908,8 @@ translated string</span> ...@@ -848,7 +908,8 @@ translated string</span>
{'i18n:name': 'email'})), {'i18n:name': 'email'})),
('i18nVariable', ('i18nVariable',
('email', ('email',
[('rawtextBeginScope', [('startTag', ('span', [('i18n:name', 'email', 'i18n')])),
('rawtextBeginScope',
('\n ', ('\n ',
4, 4,
(3, 4), (3, 4),
...@@ -863,14 +924,14 @@ translated string</span> ...@@ -863,14 +924,14 @@ translated string</span>
('$request/submitter$', ('$request/submitter$',
[('rawtextOffset', ('user@host.com', 13))])), [('rawtextOffset', ('user@host.com', 13))])),
('endScope', ()), ('endScope', ()),
('rawtextOffset', ('</a>', 4))], ('rawtextOffset', ('</a>', 4)),
('rawtextOffset', ('</span>', 7))],
None, None,
0)), False)),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('\n', 0))])), ('rawtextColumn', ('\n', 0))])),
('endScope', ()), ('endScope', ()),
('rawtextColumn', ('</p>\n', 0)) ('rawtextColumn', ('</p>\n', 0))])
])
def check_i18n_name_with_tal_content(self): def check_i18n_name_with_tal_content(self):
# input/test27.html # 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