Seems translated texts cannot be used as keys for dictionaries or
values to be iterated for lists/tuples:

SPONSOR_LEVELS=(T("Organizer"),T("Sponsor"))
...
random.shuffle(response.sponsors[SPONSOR_LEVELS[1]])

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
    exec ccode in environment
  File "/home/web2py/applications/rafaela2010/models/menu.py", line
85, in <module>
    random.shuffle(response.sponsors[SPONSOR_LEVELS[1]])
KeyError: <gluon.languages.lazyT object at 0x89620ec>

Iterating over a T'ed values causes the same bug:

Traceback (most recent call last):
  File "gluon/restricted.py", line 178, in restricted
    exec ccode in environment
  File "/home/web2py/applications/raf10dev/views/plugin_flatpages.html",
line 112, in <module>
    for sponsor_level in SPONSOR_LEVELS:
KeyError: <gluon.languages.lazyT object at 0x89e2f4c>


Workaround:
------------------

Converting translated text to str solves the problem:

random.shuffle(response.sponsors[str(SPONSOR_LEVELS[1])])

or

for sponsor_level in [str(l) for l in SPONSOR_LEVELS]:

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com

Reply via email to