[Zope-CMF] Metadata Tool stores in non-unicode

Tim Terlegård tim at se.linux.org
Wed Aug 30 09:03:04 EDT 2006


> >The Metadata Tool seems to store strings using the str type. I'd  
> >like to
> >have them stored in unicode. For instance  
> >MetadataTool.listAllowedSubjects()
> >returns a tuple with str-ojects, I'd like a tuple with unicode- 
> >objects.
> >
> >Other people than me must have been bitten by this? How do I resolve
> >this?
> 
> I just looked at the code and cannot see any conversion that converts  
> to normal strings. Can you be a bit more clear and describe exactly  
> what you did, what the expected outcome was supposed to be, and what  
> outcome you got instead?

I go to ZMI -> portal_metadata -> Elements -> Subjects, then I add a few
values to a vocabulary. By printing the values in
CMFDefault/MetadataTool.py/MetadataElementPolicy/edit() I can see that
they are of str type, not unicode. I don't know by which type they are
supposed to be stored, but it seems to me it's not unicode.

Later I do something like:

mtool = getToolByName(self, 'portal_metadata'(
subjects = mtool.listAllowedSubjects(content_type='Event')
for subject in subjects:
    print type(subject)

If I print what's in subjects I can see those are of type str.

Do you mean that the metadata tool should store everything in unicode?

Tim


More information about the Zope-CMF mailing list