[Zope-CMF] GenericSetup and unicode

Florent Guillaume fg at nuxeo.com
Sat Dec 24 11:47:46 EST 2005


I have some iso-8859-15 strings that I want to export (I don't care  
about the <?xml?> header encoding).

Today if I do
   value = unicode(value, 'iso-8859-15')
   child.setAttribute('value', value)
I get an error on write:

   File "/Users/fg/zope/zope29/Products/GenericSetup/utils.py", line  
685, in exportObjects
     exportObjects(sub, path+'/', context)
   File "/Users/fg/zope/zope29/Products/GenericSetup/utils.py", line  
681, in exportObjects
     context.writeDataFile(filename, body, exporter.mime_type)
   File "/Users/fg/zope/zope29/Products/GenericSetup/context.py",  
line 388, in writeDataFile
     self._archive.addfile( info, stream )
   File "/usr/local/lib/python2.4/tarfile.py", line 1302, in addfile
     copyfileobj(fileobj, self.fileobj, tarinfo.size)
   File "/usr/local/lib/python2.4/tarfile.py", line 173, in copyfileobj
     dst.write(buf)
   File "/usr/local/lib/python2.4/gzip.py", line 202, in write
     self.crc = zlib.crc32(data, self.crc)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in  
position 297: ordinal not in range(128)

Is that expected? For now I convert to utf-8 instead of unicode, but  
it feels like the writer should take care of that, no? Or is that a  
minidom restriction?

Florent

-- 
Florent Guillaume, Nuxeo (Paris, France)   Director of R&D
+33 1 40 33 71 59   http://nuxeo.com   fg at nuxeo.com





More information about the Zope-CMF mailing list