Skip to content

Commit

Permalink
Set copy flags when copying container. (#61)
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 authored and jensens committed Sep 12, 2016
1 parent 9a2f7fa commit 62539d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Expand Up @@ -15,7 +15,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.4.3 (2016-08-12)
Expand Down
16 changes: 16 additions & 0 deletions plone/dexterity/content.py
Expand Up @@ -234,6 +234,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 62539d2

Please sign in to comment.