Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep object position in parent folder when migrating with migrate_base_class_to_new_class #563

Open
laulaz opened this issue Jul 10, 2020 · 1 comment

Comments

@laulaz
Copy link
Member

laulaz commented Jul 10, 2020

When an object is migrated with migrate_base_class_to_new_class, its position in parent folder changes : the object always ends up last. Position should be kept.

The fix in our custom migration code looks like this :

from Acquisition import aq_inner
from Acquisition import aq_parent
from OFS.interfaces import IOrderedContainer
from plone.app.contenttypes.migration import dxmigration

[...]
obj_id = obj.getId()
parent = aq_parent(aq_inner(obj))
position_in_parent = None
ordered = IOrderedContainer(parent, None)
if ordered is not None:
    position_in_parent = ordered.getObjectPosition(obj_id)
if dxmigration.migrate_base_class_to_new_class(obj) and position_in_parent is not None:
    ordered.moveObject(obj_id, position_in_parent)
[...]

We should add this in the base migration script.
Any feedback on this ?

@vincentfretin
Copy link
Member

This looks like a bug to me. Can you create a PR to fix the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants