[Zope3-Users] Problem with unicode decode error

Florian Lindner mailinglists at xgm.de
Sun May 28 07:19:50 EDT 2006


Hello,
I'm reading in a file to create content objects out of this file, I'm using 
the csv.reader object for that purpose.

The name is choosen by a customized name chooser adapter:

class XGMNameChooser(NameChooser):
    implements(INameChooser)
    
    def chooseName(self, name, object):
        if IAbbreviation.providedBy(object):
            n = unicode(object.abbreviation)  <---
            if object.abbreviation in self.context:
                i = 0
                while n in self.context:
                    i += 1
                    n = unicode(object.abbreviation) + u'-' + unicode(i)
            self.checkName(n, object)
            return n
        else:
            return super(XGMNameChooser, self).chooseName(name, object)


However, if object.abbreviation contains a Umlaut (äöü) it breaks:

  File "/home/florian/Desktop/zope/lib/python/xgm/xgm.py", line 27, in 
chooseName
    n = unicode(object.abbreviation)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 2: 
ordinal not in range(128)

Generally names with umlauts seem to be possible with Zope. Umlauts put in the 
other fields of this content object seem to cause no trouble.

What's wrong with that?

Thanks,

Florian


More information about the Zope3-users mailing list