[Zope-Checkins]
SVN: Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_htmltalparser.py
Cope with TAL 1.6 bytecode changes:
Philipp von Weitershausen
philikon at philikon.de
Sun May 28 19:14:22 EDT 2006
Log message for revision 68321:
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)
Changed:
U Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_htmltalparser.py
-=-
Modified: Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_htmltalparser.py
===================================================================
--- Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_htmltalparser.py 2006-05-28 23:11:02 UTC (rev 68320)
+++ Zope/branches/ajung-zpt-end-game/lib/python/TAL/tests/test_htmltalparser.py 2006-05-28 23:14:22 UTC (rev 68321)
@@ -345,9 +345,13 @@
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 @@
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 @@
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 @@
[('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 @@
('beginScope',
{'tal:attributes': 'src string:foo.png',
'tal:replace': 'structure string:<img>'}),
- ('insertStructure',
- ('$string:<img>$',
- {'src': ('$string:foo.png$', 0, None)},
- [('startTag', ('p',
- [('tal:replace', 'structure string:<img>', 'tal'),
- ('tal:attributes', 'src string:foo.png',
- 'tal')])),
- rawtext('duh</p>')])),
+ ('optTag',
+ ('p',
+ '',
+ None,
+ 0,
+ [('startTag',
+ ('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', ()),
])
@@ -454,11 +474,16 @@
('beginScope',
{'tal:replace': 'notHere', 'tal:on-error': 'string:error'}),
('onError',
- ([('insertText', ('$notHere$',
- [('startTag', ('p',
- [('tal:on-error', 'string:error', 'tal'),
- ('tal:replace', 'notHere', 'tal')])),
- rawtext('okay</p>')]))],
+ ([('optTag',
+ ('p',
+ '',
+ None,
+ 0,
+ [('startTag',
+ ('p',
+ [('tal:on-error', 'string:error', 'tal'),
+ ('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 @@
[('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 @@
{'i18n:name': 'name', 'tal:replace': 'str:Lomax'})),
('i18nVariable',
('name',
- [('startEndTag',
+ [('optTag',
('span',
- [('tal:replace', 'str:Lomax', 'tal'),
- ('i18n:name', 'name', 'i18n')]))],
- '$str:Lomax$',
- 0)),
+ '',
+ None,
+ 1,
+ [('startEndTag',
+ ('span',
+ [('tal:replace', 'str:Lomax', 'tal'),
+ ('i18n:name', 'name', 'i18n')]))],
+ [('insertText', ('$str:Lomax$', []))]))],
+ None,
+ False)),
('rawtextBeginScope',
(' was born in\n ',
2,
@@ -604,12 +639,18 @@
{'i18n:name': 'country', 'tal:replace': 'str:Antarctica'})),
('i18nVariable',
('country',
- [('startEndTag',
+ [('optTag',
('span',
- [('tal:replace', 'str:Antarctica', 'tal'),
- ('i18n:name', 'country', 'i18n')]))],
- '$str:Antarctica$',
- 0)),
+ '',
+ None,
+ 1,
+ [('startEndTag',
+ ('span',
+ [('tal:replace', 'str:Antarctica', 'tal'),
+ ('i18n:name', 'country', 'i18n')]))],
+ [('insertText', ('$str:Antarctica$', []))]))],
+ None,
+ False)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
@@ -664,13 +705,21 @@
('',
[('rawtextBeginScope', ('\n ', 2, (2, 2), 0, {'i18n:name': 'name'})),
('i18nVariable',
- ('name',
- [('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, 0)),
+ ('name',
+ [('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',
+ [('startTag', ('span', [('i18n:name', 'country', 'i18n')])),
+ ('rawtextOffset', ('the USA', 7)),
+ ('rawtextOffset', ('</span>', 7))],
+ None,
+ False)),
('endScope', ()),
('rawtextColumn', ('.\n', 0))])),
('endScope', ()),
@@ -778,15 +827,20 @@
{'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))],
- '$here/currentTime$')),
+ ('insertTranslation',
+ ('timefmt',
+ [('rawtextOffset', ('2:32 pm', 7))],
+ '$here/currentTime$')),
+ ('rawtextOffset', ('</span>', 7))],
+ None,
+ False)),
('endScope', ()),
('rawtextOffset', ('... beep!', 9))])),
('endScope', ()),
@@ -813,14 +867,20 @@
{'i18n:name': 'jobnum', 'tal:replace': 'context/@@object_name'})),
('i18nVariable',
('jobnum',
- [('startTag',
- ('span',
- [('tal:replace', 'context/@@object_name', 'tal'),
- ('i18n:name', 'jobnum', 'i18n')])),
- ('rawtextOffset', ('NN', 2)),
- ('rawtextOffset', ('</span>', 7))],
- '$context/@@object_name$',
- 0)),
+ [('optTag',
+ ('span',
+ '',
+ None,
+ 0,
+ [('startTag',
+ ('span',
+ [('tal:replace', 'context/@@object_name', 'tal'),
+ ('i18n:name', 'jobnum', 'i18n')]))],
+ [('insertText',
+ ('$context/@@object_name$',
+ [('rawtextOffset', ('NN', 2))]))]))],
+ None,
+ False)),
('endScope', ())])),
('endScope', ()),
('rawtextColumn', ('</span>\n', 0))
@@ -848,7 +908,8 @@
{'i18n:name': 'email'})),
('i18nVariable',
('email',
- [('rawtextBeginScope',
+ [('startTag', ('span', [('i18n:name', 'email', 'i18n')])),
+ ('rawtextBeginScope',
('\n ',
4,
(3, 4),
@@ -863,14 +924,14 @@
('$request/submitter$',
[('rawtextOffset', ('user at 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
More information about the Zope-Checkins
mailing list