Problem with WebDAV and non-ascii titles
Hi, I have a problem with accessing files with non-ascii titles via Enfold Desktop (WebDAV)- Zope 2.10.4). Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module webdav.Resource, line 286, in PROPFIND Module webdav.davcmds, line 124, in apply Module OFS.PropertySheets, line 344, in dav__allprop UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 47: ordinal not in range(128) Is it a bug? I solved my problem with extra line: -------------- + result = [r.decode('ascii', 'ignore') for r in result] result='\n'.join(result) return propstat % (self.xml_namespace(), result, '200 OK', '') -------------- Pawel Lewicki
Pawel Lewicki wrote at 2008-3-28 15:52 +0100:
I have a problem with accessing files with non-ascii titles via Enfold Desktop (WebDAV)- Zope 2.10.4).
Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module webdav.Resource, line 286, in PROPFIND Module webdav.davcmds, line 124, in apply Module OFS.PropertySheets, line 344, in dav__allprop UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 47: ordinal not in range(128)
WebDAV is XML technology, therefore essentially unicode. Apparently, your "title"s are plain strings. Therefore, Python needs to convert them to unicode at the WebDAV boundary. Obviously, an encoding is necessary to do this -- and as no explicit encoding is given, Python's defaultencoding is used (which defaults to "ascii"). The most proper solution would be to make your "title"s unicode. If all your plain strings use a common encoding, then you can set Python's defaultencoding to this encoding. You must do that at startup (e.g. in "sitecustomize.py"), as "setdefaultencoding" is removed from "sys" after startup. -- Dieter
Dieter Maurer wrote:
Pawel Lewicki wrote at 2008-3-28 15:52 +0100:
I have a problem with accessing files with non-ascii titles via Enfold Desktop (WebDAV)- Zope 2.10.4).
Traceback (innermost last): Module ZPublisher.Publish, line 119, in publish Module ZPublisher.mapply, line 88, in mapply Module ZPublisher.Publish, line 42, in call_object Module webdav.Resource, line 286, in PROPFIND Module webdav.davcmds, line 124, in apply Module OFS.PropertySheets, line 344, in dav__allprop UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 47: ordinal not in range(128)
WebDAV is XML technology, therefore essentially unicode.
Apparently, your "title"s are plain strings. Therefore, Python needs to convert them to unicode at the WebDAV boundary. Obviously, an encoding is necessary to do this -- and as no explicit encoding is given, Python's defaultencoding is used (which defaults to "ascii").
The most proper solution would be to make your "title"s unicode.
If all your plain strings use a common encoding, then you can set Python's defaultencoding to this encoding. You must do that at startup (e.g. in "sitecustomize.py"), as "setdefaultencoding" is removed from "sys" after startup.
Thanks a lot. ------- ZOPE_INSTANCE/lib/python/sitecustomize.py : import sys sys.setdefaultencoding('utf-8') ------- works like a charm. Pawel Lewicki
participants (2)
-
Dieter Maurer -
Pawel Lewicki