Skip to content

Commit

Permalink
Set copy flags when copying container.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jone committed Sep 1, 2016
1 parent 2b45bc7 commit d385d80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions plone/dexterity/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d385d80

Please sign in to comment.