[Zope-CMF] SVN: Products.CMFCore/branches/2.2/Products/CMFCore/exportimport/content.py remove type check that seem useless

Hanno Schlichting hanno at hannosch.eu
Thu Jan 13 09:03:22 EST 2011


On Thu, Jan 13, 2011 at 2:17 PM, Godefroid Chapelle <gotcha at bubblenet.be> wrote:
> You make me wonder if I am actually reproducing something wrong in my
> tests setup : am I allowed to set a unicode value in Title and Description ?

I'm not sure what the Unicode story is like for CMF. I'd expect there
to be no conversion at any level, so whatever you set via a mutator is
also what you get from the accessor. That means there could be both
Unicode or encoded strings in the encoding as stored in the properties
tool.

In Plone the situation is a different. If you have Archetypes you can
pass in either utf-8 or Unicode into mutator methods, it will
internally always store Unicode and the accessor will always return
utf-8. But if you have Dexterity you will only set Unicode and get
Unicode from objects. Strings encoded in a different encoding than
utf-8 aren't supported since Plone 3.0 - so the site_encoding value is
meaningless here.

So any code that uses mutators or sets attributes should use Unicode.
Any code that gets values from accessor or direct attributes needs to
handle both Unicode and utf-8 in Plone - in CMF it should also handle
the additional arbitrary encoding set as site_encoding (which could be
latin-1).

There's more rules like all the data in one catalog index has to be in
the same encoding or be all Unicode (or you'll get errors inside the
BTree logic trying to compare mixed types). In Plone we changed page
templates to except both utf-8 and Unicode inside TAL constructs and
convert them to Unicode for you. In CMF that doesn't happen, so you
need to be consistent.

Unicode transition fun :)
Hanno


More information about the Zope-CMF mailing list