UnicodeDecodeError

Yuri <[email protected]>
Newsgroups gmane.comp.web.zope.general
Message-ID <[email protected]>
Hi!

  I've an Zope application, basically postgres + zpt.

  The postgres db has been upgraded to 8.5, the data inside is utf-8 
(dumped and checkd it), the pg adapeter is the latest, and the "*Z 
Psycopg 2 Database Connection" is configured to use utf-8.* Zope is  
2.12.20 + latest security fix.

  When I try to do:

<span tal:replace="result/?column" /> (result came from an ZSQL method) 
I get an UnicodeDecodeError:

Traceback (innermost last):
   Module ZPublisher.Publish, line 127, in publish
   Module ZPublisher.mapply, line 77, in mapply
   Module ZPublisher.Publish, line 47, in call_object
   Module Shared.DC.Scripts.Bindings, line 324, in __call__
   Module Shared.DC.Scripts.Bindings, line 361, in _bindAndExec
   Module Products.PageTemplates.ZopePageTemplate, line 335, in _exec
   Module Products.PageTemplates.ZopePageTemplate, line 432, in pt_render
   Module Products.PageTemplates.PageTemplate, line 80, in pt_render
   Module zope.pagetemplate.pagetemplate, line 113, in pt_render
   Module zope.tal.talinterpreter, line 271, in __call__
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 888, in do_useMacro
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 946, in do_defineSlot
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 533, in do_optTag_tal
   Module zope.tal.talinterpreter, line 518, in do_optTag
   Module zope.tal.talinterpreter, line 513, in no_tag
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 821, in do_loop_tal
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 821, in do_loop_tal
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 852, in do_condition
   Module zope.tal.talinterpreter, line 343, in interpret
   Module zope.tal.talinterpreter, line 376, in do_startEndTag
   Module zope.tal.talinterpreter, line 405, in do_startTag
   Module zope.tal.talinterpreter, line 502, in attrAction_tal
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 38: 
ordinal not in range(128)

if I do:

<span tal:replace="python:str(result['column']).decode('utf-8')" /> it 
works. (I use str because I've also dates in the record, otherwise I 
could not decode being it not a string)

I've several zpt to fix, and I would like it to work as it should. My 
analisys is that result['column'] is seen as a plain string with \xx 
characters inside, and decode just transform it in something that Zope 
recognize as utf-8 when it prints it.

Anyway, any idea?
_______________________________________________
Zope maillist  -  [email protected]
https://mail.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists -
 https://mail.zope.org/mailman/listinfo/zope-announce
 https://mail.zope.org/mailman/listinfo/zope-dev )
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.