Question

I have a folder content type that derives from ATBTreeFolder which in plone 4(actually in Products.Archetypes) sets the ordering to "unordered".

If I go ahead and set the ordering to be ordered, which is just an empty string, the folder is confused and doesn't show me the contents of the folder. In fact, I'll get error like this:

  File "buildout-cache/eggs/plone.folder-1.0.1-py2.6.egg/plone/folder/default.py", line 130, in getObjectPosition
    raise ValueError('No object with id "%s" exists.' % id)
ValueError: No object with id "someid" exists.

I assume there is some migration that is required to be run to have ordering set on a folder that is originally unordered but I could not find anything available for that sort of situation in plone.app.folder and plone.folder.

Was it helpful?

Solution

I have written an upgrade script that seems to solve the problem:

catalog = getToolByName(context, 'portal_catalog')
for brain in catalog(portal_type='MyType'):
    obj = brain.getObject()
    if obj._ordering == 'unordered':
        obj.setOrdering(u'')
    order = obj.getOrdering()
    for id in obj._tree:
        if id not in order._order():
            order.notifyAdded(id)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top