Diez B. Roggisch wrote:
Am 11.03.2011 um 12:33 schrieb jose soares:
Diez B. Roggisch wrote:
Am 11.03.2011 um 09:27 schrieb jose soares:
Hi all,
I have this error raised by kid in Turbogears 1.1.1 :
...
"/home/admin/.VE-SICER2.x-x86_64-19.04.2010/lib/python2.6/site-packages/kid-0.9.6-py2.6.egg/kid/template_util.py",
line 146, in make_attrib
v = generate_attrib(v, encoding)
File
"/home/admin/.VE-SICER2.x-x86_64-19.04.2010/lib/python2.6/site-packages/kid-0.9.6-py2.6.egg/kid/template_util.py",
line 178, in generate_attrib
item = generate_attrib(item, encoding)
File
"/home/admin/.VE-SICER2.x-x86_64-19.04.2010/lib/python2.6/site-packages/kid-0.9.6-py2.6.egg/kid/template_util.py",
line 161, in generate_attrib
return to_unicode(attrib, encoding)
File
"/home/admin/.VE-SICER2.x-x86_64-19.04.2010/lib/python2.6/site-packages/kid-0.9.6-py2.6.egg/kid/parser.py",
line 206, in to_unicode
return unicode(value, encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in
position 19: ordinal not in range(128)
Error location in template file
'/home/admin/trunk/BASE/view/templates/controlli/scheda_ua.kid'
on line 34 between columns 50 and 88:
... </h2> ${form.display(**form_params)} </div>
value = 'Attività ' and encoding = 'ascii'
I would like to assign 'utf-8' to encoding param but I don't know
how to change it.
in my kid template I have this line: (form_params is a dictionary
which contains the unicode string 'attivittà ' )
I doubt that. The problem is that something tries to *decode* a
byte-string to get a unicode-object. So I presume you have a
(possibly UTF-8-encoded) *bytestring* with the value 'attivittà '.
What does a repr(form_params["the_key"]) tell you?
Diez
Here the repr output, Diez:
(Pdb) repr(form_params['options']['rischi'])
"[{'scheda_valore': {'select': [['', ''], [u'Elevata', u'Elevata'],
[u'Discreta', u'Discreta'], [u'Scarsa', u'Scarsa'],
[u'Insufficiente', u'Insufficiente']]}}, {'scheda_valore': {'select':
[['', ''], [u'Completo', u'Completo'], [u'Adeguato', u'Adeguato'],
[u'Da integrare', u'Da integrare'], [u'Inadegato', u'Inadegato']]}},
{'scheda_valore': {'select': [['', ''], [u'Elevata', u'Elevata'],
[u'Discreta', u'Discreta'], [u'Scarsa', u'Scarsa'],
[u'Insufficiente', u'Insufficiente']]}}, {'scheda_valore': {'select':
[['', ''], [u'buone', u'buone'], [u'discrete', u'discrete'],
[u'scarse', u'scarse'], [u'insufficienti', u'insufficienti']]}},
{'scheda_valore': {'select': [['', ''], [u'Nuova costruzione',
u'Nuova costruzione'], [u'Recente ristrutturazione', u'Recente
ristrutturazione'], [u'Abbastanza recente', u'Abbastanza recente'],
[u'Datate', u'Datate']]}}, {'scheda_valore': {'select': [['', ''],
[u'Impianto familiare', u'Impianto familiare'], [u'Impianto piccolo',
u'Impianto piccolo'], [u'Impianto medio', u'Impianto medio'],
[u'Impianto industriale', u'Impianto industriale']]}},
{'scheda_valore': {'select': [['', ''], [u'Artigianale',
u'Artigianale'], [u'Industriale Medio', u'Industriale Medio'],
[u'Industriale Grande', u'Industriale Grande'], [u'stabilimento con
pi\\xf9 riconoscimenti 1774', u'stabilimento con pi\\xf9
riconoscimenti 1774']]}}, {'scheda_valore': {'select': [['', ''],
[u'Applicato e adeguato', u'Applicato e adeguato'], [u'Carenze
minori', u'Carenze minori'], [u'Carenze maggiori', u'Carenze
maggiori'], [u'Inadeguato non applicato', u'Inadeguato non
applicato']]}}, {'scheda_valore': {'select': [['', ''], [u'Non
significative o formali', u'Non significative o formali'], [u'Non
significative o formali ripetute', u'Non significative o formali
ripetute'], [u'Sostanziali o gravi, isolate e risolte', u'Sostanziali
o gravi, isolate e risolte'], [u'Sostanziali o gravi, ripetute o non
risolte', u'Sostanziali o gravi, ripetute o non risolte']]}},
{'scheda_valore': {'select': [['', ''], [u'Elevata', u'Elevata'],
[u'Discreta', u'Discreta'], [u'Scarsa', u'Scarsa'],
[u'Insufficiente', u'Insufficiente']]}}]"
as you see a couple of elements of the list contain:
[u'stabilimento con pi\\xf9 riconoscimenti 1774', u'stabilimento con
pi\\xf9 riconoscimenti 1774']
Yep, that looks good. So to remove another variable from the equation
- what happens if you don't render the widget/form, but instead fill
in the value in question directly? Only the final unicode-string! Not
the whole dict. If that works, the widget is the problem. So we will
need the deklaration of it, I guess.
Diez
Yes, Diez, If I pass only the single string it works.
j
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en.