Usted está aquí: Inicio CS-Workshop CS-Workshop Blog Topics reorder


I can't reorder elements in a Plone folder!

by Mikel Larreategi — última modificación 11/11/2008 17:25

Recently I had a problem in a website we are currently developing to reorder some custom content-types in Plone folder.

We are currently building a website that has many customized content-types. In the main folder of the structure we are building, the client wants to reorder elements freely, like in a normal Plone folder. Well, the main folder of the structure is currently a Plone folder, so "no problem" I said, just go to Contents tabs and reorder the elements. But... aghh !!! I couldn't reorder the items !!

I started investigating what was going on, putting a pdb here and there, and found a curious thing: the items stored in the folder were some archetypes based custom objects with a portal type with a space in its name. This portal type was "Product Line". The reordering code compared the items inside it and checked whether the item was actually in it looking at its _objects attribute, nothing special til here. But the check was not safe enough.

The code looked at the Metatype of the FTIs in the portal_types tool to check whether the element which was being reordered was currently a CMF object. But the Metatype of the FTI wasn't the same as the meta type of the object, because the Metatype of the FTI was the actual portal type of the object.

Moreover, the _objects attribute wasn't modified when the meta type of the object was changed, so it wasn't enough the change just the meta_type. I had to write a migration script to change the _objects attribute of the folder to change "ProductLine" with "Product Line". That change made my custom objects orderable.