[Zope-dev] Localizer and UnicodeError

Milos Prudek prudek at bvx.cz
Tue Dec 16 11:38:17 EST 2003


I want to move my Localizer "LocalContent" instances from Localizer
0.8.1 to Localizer 1.0.1

My Zope 2.5.1 was updated with all necessary unicode patches.

The problem: After converting LocalContent instances in one folder to
Unicode, I cannot access the management screen. The error message is:

Error Type: UnicodeError
Error Value: ASCII encoding error: ordinal not in range(128)

The same error is triggered when displaying the titles in that folder:

script_1:

for x in context.objectValues('LocalContent'):
     print x.id, ":" x.title
return printed

... and is not trigered if I only list the ids.

I believe that this kind of error appears when Zope is trying to display
Unicode characters and legacy-encoded characters (such as ISO-8859-2 or
Win1250) at the same time.

The title attribute of LocalContent objects is displayed in the ZMI. Of
course, the title attribute of LocalContent objects has many language
versions, and Zope (I presume) displays in the ZMI the language version
according to my browser's language setting.

I do not understand why script_1 triggers it.

But most importantly I do not know how to get out of this mess.

This is the External script used to do the conversion to Unicode:
def cvt(objVal):
     # for x in context.objectValues('LocalContent'):
     log = []
     for x in objVal:
         log_line = x.id + ': '
         local_properties = {}
         for id, v in x._local_properties.items():
             log_line += '  ' + id
             local_properties[id] = {}
             for lang, v in v.items():
                 local_properties[id][lang] = unicode(v, 'cp1250')
         x._local_properties = local_properties
         log.append(log_line)
     return log

-- 
Milos Prudek







More information about the Zope-Dev mailing list