Edgewall Software

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#162 closed defect (fixed)

Error with attribute handling in i18n filter

Reported by: anonymous Owned by: cmlenz
Priority: minor Milestone: 0.5
Component: General Version: 0.4.4
Keywords: Cc:

Description

When using the i18n filter in both version 0.4.4 and the trunk, I receive the following traceback

  File "foo\templating.py", line 66, in render_template
    return stream.render('xhtml').strip()
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\core.py", line 172, in render
    return encode(generator, method=method, encoding=encoding)
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\output.py", line 45, in encode
    output = u''.join(list(iterator))
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\output.py", line 294, in __call__
    for kind, data, pos in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\output.py", line 555, in __call__
    for kind, data, pos in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\output.py", line 661, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\output.py", line 495, in __call__
    for ev in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\core.py", line 273, in _ensure
    for event in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\template\base.py", line 521, in _include
    for event in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\template\markup.py", line 250, in _match
    for event in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\template\base.py", line 496, in _exec
    for event in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\template\base.py", line 450, in _eval
    for kind, data, pos in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\template\base.py", line 504, in _flatten
    for event in stream:
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\filters\i18n.py", line 207, in __call__
    new_substream = list(self(substream, ctxt, msgbuf=msgbuf))
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\filters\i18n.py", line 207, in __call__
    new_substream = list(self(substream, ctxt, msgbuf=msgbuf))
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\filters\i18n.py", line 207, in __call__
    new_substream = list(self(substream, ctxt, msgbuf=msgbuf))
  File "C:\Programme\Python-2.5\lib\site-packages\genshi-0.4.4-py2.5.egg\genshi\filters\i18n.py", line 156, in __call__
    isinstance(attrs.get(xml_lang), basestring):
AttributeError: 'list' object has no attribute 'get'

The referenced part of the template is this:

                <td>
                    <span py:if="not event.started" class="icon-waiting" title="waiting">&nbsp;</span>
                    <span py:if="event.started" class="icon-running" title="running">&nbsp;</span>
                </td>

In genshi\filters\i18n.py, I appended a debug statement after line 154 so it now looks like this:

                tag, attrs = data
                print repr(attrs)

As a result, STDOUT shows these lines before the exception occurs:

Attrs()
Attrs()
Attrs()
Attrs([(QName(u'style'), u'white-space: nowrap;')])
Attrs()
Attrs([(QName(u'class'), u'icon-admin'), (QName(u'title'), u'created by you')])
Attrs()
Attrs([(QName(u'class'), u'icon-protected'), (QName(u'title'), u'password protec
ted')])
Attrs()
[(QName(u'class'), u'icon-waiting'), (QName(u'title'), u'wartet')]

The last one is interesting since the list is not wrapped inside an Attrs instance. Also, the word 'wartet' has been translated, while the others have not.

-- Jochen Kupperschmidt

Change History (2)

comment:1 follow-up: Changed 17 years ago by cmlenz

  • Resolution set to fixed
  • Status changed from new to closed

Should be fixed in [783]. Thanks for the detailed report.

About the not-translated “title” attributes: were there actually translations that should have been substituted in? The I18n filter will only replace the attributes if it finds actual translations.

comment:2 in reply to: ↑ 1 Changed 17 years ago by anonymous

Thanks for fixing it.

Replying to cmlenz:

About the not-translated “title” attributes: were there actually translations that should have been substituted in? The I18n filter will only replace the attributes if it finds actual translations.

No, there were no translations for the other title attributes. I think the last sentence in the bug report can be ignored then.

-- Jochen Kupperschmidt

Note: See TracTickets for help on using tickets.