Re: UnicodeDecodeError: 'ascii' codec can't decode byte
danieltellez <[email protected]> Mon, 14 May 2007 09:10:38 +0200
| Newsgroups | gmane.comp.web.zope.cps.devel |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Hello: > > I'm dealing with a portal (CPS 3.4.4 - Ubuntu Feisty Fawn) with > Spanish and English languages. I've got portal_translations installed. > > I get the next error > > UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position > 142: ordinal not in range(128). > > when I try to post in a forum with a latin character in title, > description, etc, like that: > > ({'author': 'V\xedctor', > 'creation': DateTime('2007/05/10 > 12:50:12.835 GMT-4'), > 'id': 'problemas-con-nokia-628x', > 'locked': False, > 'message': 'Parece ... modelo de > m\xf3vil. Al iniciar la aplicaci\xf3n y realizar algunos pasos aparece > una excepci\xf3n de OutOfMemory. Por lo que he visto este modelo de > m\xf3vil tiene ....<br />Como soluci\xf3n se comenta que cambiando el > Firmware del dispositivo se soluciona el problema. Espero que as\xed > podr\xe1is ', > 'parent_id': None, > 'published': True, > 'review_state': 'published', > 'subject': 'Problemas con Nokia 628x'}, > ())], > > Anyone knows why? > > > We found a solution: In post_tree.py (CPSForum), at line 145, we do the next changes: author = str(post['author']) posterName = author posterName = cgi.escape(context.getPosterName(author)) if isinstance(posterName, unicode): posterName = str(posterName.encode("iso8859-15")) else: posterName = str(posterName) fullname = '<a href="javascript:void(0)" onclick="javascript:window.open(\'popupdirectory_entry_view?dirname=members&id=' + author + '\',\'wclose\',\'width=500,height=200,scrollbars=yes,toolbar=no,status=no,resizable=yes,left=20,top=30\')">' +\ posterName + '</a>' instead of: fullname = '<a href="javascript:void(0)" onclick="javascript:window.open(\'popupdirectory_entry_view?dirname=members&id=' + post['author'] + '\',\'wclose\',\'width=500,height=200,scrollbars=yes,toolbar=no,status=no,resizable=yes,left=20,top=30\')">' +\ cgi.escape(context.getPosterName(post['author'])) + '</a>' We've got problems with "posterName", because it returns an incorrectly encoded value. In other hand, we've made an improve to getPosterName method: mtool = context.portal_membership + author = mtool.getFullnameFromId(post_author) + if not author: + author = post_author - return mtool.getFullnameFromId(post_author) + return author This changes gives us fullname of authenticated user or the poster name in case of anonymous user. The original method only gives us the name in authenticated users. -- Daniel Téllez Sabán. Yerbabuena Software. Dpto I+D. [email protected] http://www.yerbabuena.es Tlf/Fax: 902 995 246 Móvil: 615 051 283 _______________________________________________ cps-devel mailing list http://lists.nuxeo.com/mailman/listinfo/cps-devel