meta_types containing spaces break folder_contents sorting

If you experience problems with sorting/reordering items in folder_contents as i did recently
this might save you from spending > 2 hrs with debugging.

If your folder does contain custom or third party content types that have a space ” ” in their meta_type (see portal_type/ ‘Product meta type’) you most probably ran into the same problem:

If you defined the meta_type of your content type in profiles/default/types/My_Type.xml like that:

<object name="My Type">
  ...
  <property name="content_meta_type">My Type</property>
  ...

objects of your type will have ‘MyType’ as meta_type:

>>> _ = folder.invokeFactory('My Type', 'mytype')
>>> folder.mytype.meta_type
'MyType'

Products.Archetypes.OrderedBaseFolder.moveObjectsByDelta only takes CMF-Types into account.

This is done by using only those ids returned by getCMFObjectsSubsetIds which lists all meta_types registered in portal_types and compares them to the meta_type of the objects contained in the folder.

Since these differ for meta types containing spaces you’ll experience very strange behaviour when reordering items in a folder containing some objects of type ‘My Type’.

Solution:

In case you’re responsible for the product, simply change the GS profile for the portal type from <property name="content_meta_type">My Type</property> to <property name="content_meta_type">MyType</property> and reinstall the product.

In case you’re using a third party product you’re out of luck.
This is why I filed a bug (https://dev.plone.org/plone/ticket/8161)