Hi again,

I have two use cases where I got errors:

The first one:

{{{
title = mcat('title_ipractice_' + btool.ptool.CONTENTS_ID)
title = title.encode('iso8859-15')
docDef = {TITLE:title, DESCRIPT:'', HIDDE:0}
}}}

with the encoding proposed by Yves works fine.

The second use case, where I didn't have such luck is:

{{{
4  title = object.title_or_id()
5  title = title.encode('iso8859-15')
6  username = member.getProperty('fullname')
7  username = username.encode('iso8859-15')
8  logTitle = username + mcat(action + '_by') + title
9  logTitle = logTitle.encode('iso8859-15')
}}}

where title is the title of a document which is being created in the current 
transaction (I'm implementing a who-did-what system using portal_eventservice).

I tried to encode the title using utf8, iso8859-15 and latin-1 but this errors 
persists:

{{{
  File "Script (Python)", line 5, in getTranslatedLogMessage
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf3 in position 1: ordinal 
not in range(128)
> /root/instances/saludinnova2/Script (Python)(7)getTranslatedLogMessage()   
}}}

The snippet above works well without any statement related to title or with an 
ascii title.

I used iso8859-15 because is the encoding that I use in my web browser but I'm 
not sure if this is what I should use in the code or if I should ask what 
encoding is currently being used in the title. How may I do that?

Thank you very much for your help.

JoseLuis de la Rosa Triviño 
Becario Área de Sistemas de Información 
FUNDACIÓN IAVANTE 
[EMAIL PROTECTED] 
Tel. 951 015 300 


Este correo electrónico y, en su caso, cualquier fichero anexo, contiene 
información confidencial exclusivamente dirigida a su(s) destinatario(s). Toda 
copia o divulgación deberá ser autorizada por IAVANTE.

This e-mail and any attachments are confidential and exclusively directed to 
its adressee(s). Any copy or distribution will have to be authorized by IAVANTE.



-----Mensaje original-----
De: Julien Anguenot [mailto:[EMAIL PROTECTED] 
Enviado el: viernes, 02 de junio de 2006 14:33
Para: Yves Bastide
CC: [email protected]
Asunto: Re: [CPS-devel] Re: UnicodeDecodeError indexing translated titleof 
document.

Yves Bastide wrote:
> JoseLuis de la Rosa Triviño wrote:
> [...]
>> UnicodeDecodeError: 'ascii' codec can't decode byte 0xed in position
>> 10: ordinal not in range(128)
>>> /opt/zope2.9/lib/python/Products/PluginIndexes/common/UnIndex.py(207)insertForwardIndexEntry()
>>>
>> -> indexRow = self._index.get(entry, _marker)
>> (Pdb) entry
>> u'Carlos Gonzalez created aaaaaaaaaaaaaa'
> 
> Your title is an Unicode string; you could try converting it to a string
> in your string:
> 
>   title = mcat('title_' + btool.ptool.CONTENTS_ID)
> + title = title.encode('iso8859-15')
>   docDef = {TITLE:title, DESCRIPT:'', HIDDE:0}
> 
> 
> (perhaps testing first that title is really unicode)

yup but it seems that translation_service is now returning unicode
strings. (I didn't follow the changes recently)

You may want to check this document to deal with your unicode conversion :

http://www.reportlab.com/i18n/python_unicode_tutorial.html

Zope2 is a real pain when it comes to unicode...

Keep us posted please.

        J.

-- 
Julien Anguenot | Nuxeo R&D (Paris, France)
Open Source ECM - www.nuxeo.com
CPS Platform - http://www.cps-project.org
Mobile: +33 (0) 6 72 57 57 66

_______________________________________________
cps-devel mailing list
http://lists.nuxeo.com/mailman/listinfo/cps-devel

Reply via email to