From d385d80ac11c4a172e160089c3153651a80340aa Mon Sep 17 00:00:00 2001 From: Jonas Baumann Date: Wed, 31 Aug 2016 17:10:18 +0200 Subject: [PATCH] Set copy flags when copying container. When copying a DX container which has AT children, the UID of the AT children was not updated. The reason for the error is that the DX container copy did not have the _v_is_cp flag while the AT children were processed and thus the flag was not properly delegated. By copying the _v_is_cp and _v_cp_refs flags to the copy we have the same behavior as it used to be with AT, which does fix the error. --- CHANGES.rst | 3 ++- plone/dexterity/content.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGES.rst b/CHANGES.rst index 4d61c82a..97e35f58 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -14,7 +14,8 @@ New features: Bug fixes: -- *add item here* +- Fix error when copying DX containers with AT children which caused the + children to not have the UID updated properly. [jone] 2.2.7 (2016-05-05) diff --git a/plone/dexterity/content.py b/plone/dexterity/content.py index 167a3edc..1222064f 100644 --- a/plone/dexterity/content.py +++ b/plone/dexterity/content.py @@ -221,6 +221,22 @@ def _verifyObjectPaste(self, obj, validate_src=True): 'You can not add the copied content here.' ) + def _getCopy(self, container): + # Copy the _v_is_cp and _v_cp_refs flags from the original + # object (self) to the new copy. + # This has impact on how children will be handled. + # When the flags are missing, an Archetypes child object will not have + # the UID updated in some situations. + # Copied from Products.Archetypes.Referenceable.Referenceable._getCopy + is_cp_flag = getattr(self, '_v_is_cp', None) + cp_refs_flag = getattr(self, '_v_cp_refs', None) + ob = super(PasteBehaviourMixin, self)._getCopy(container) + if is_cp_flag: + setattr(ob, '_v_is_cp', is_cp_flag) + if cp_refs_flag: + setattr(ob, '_v_cp_refs', cp_refs_flag) + return ob + @implementer( IDexterityContent,