hello,

i'm new to zope, cps, and python, and i have to correct some problems on a
customer's platform:

----
Zope Version    (Zope 2.9.4-final, python 2.4.4, linux2) 
Python Version  2.4.4 (#2, Apr 15 2008, 23:43:20) [GCC 4.1.2 20061115
(prerelease) (Debian 4.1.1-21)] 
System Platform         linux2 
SOFTWARE_HOME   /ZOPE/Binaries_v2-9-4/lib/python 
ZOPE_HOME       /ZOPE/Binaries_v2-9-4 
INSTANCE_HOME   /ZOPE/Instances_v2-9-4/ZCLIENT1 
CLIENT_HOME     /ZOPE/Instances_v2-9-4/ZCLIENT1/var 
Network Services        ZServer.HTTPServer.zhttp_server (Port: 8080)
----
CPS Last upgraded version 3.4.0
Default portal charset         iso-8859-15
----

here's the problem:
when a user fills a form to create an object, with some latin characters in
the title, it returns that message:
......
Module Products.PluginIndexes.common.UnIndex, line 221, in
insertForwardIndexEntry 
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 31:
ordinal not in range(128)
......

i first thought that the problem was in
Products.PluginIndexes.common.UnIndex, so i modified the line 221 from:
....
>indexRow = self._index.get(entry, _marker)
....
to:
....
>indexRow = self._index.get(toUTF8(entry), _marker)
....
but the error was still there

then someone told me to work on data directly after the POST of the form, i
then found the class CPSStringWidget in BasicWidgets.py and modified the
code of the 'validate' method from:
....
>datamodel[self.fields[0]] = v
....
to:
....
> if isinstance(v, unicode):
>    fvalue = str(v.encode("iso8859-15"))
> else:
>    fvalue = str(v)
> datamodel[self.fields[0]] = fvalue
....
i also tried this:
----
>datamodel[self.fields[0]] = toUTF8(v)
----
but still with no success

the method toUTF8 is as below:
----
>def toUTF8(s):
>    if not isinstance(s, unicode):
>         s = unicode(s, default_encoding)
>    return s.encode('utf-8')

now i don't know where i can act to correct that problem.
the error occurs only when using latin characters in title, there's no error
whith latin characters in description for example.

could anybody here bring some help?

thx by advance
alain scieur

-- 
View this message in context: 
http://www.nabble.com/%22UnicodeDecodeError%3A-%27ascii%27-codec-can%27t-decode-byte-...%22-tp20340022p20340022.html
Sent from the cps-devel mailing list archive at Nabble.com.

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

Reply via email to