Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Problem:** 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. **Solution:** 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. - Issue: plone/Products.CMFPlone#1735 - Plone 4 fix: plone/plone.dexterity#60 - Plone 5 fix: plone/plone.dexterity#61
- Loading branch information
Showing
10 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:five="http://namespaces.zope.org/five"> | ||
xmlns:i18n="http://namespaces.zope.org/i18n" | ||
xmlns:monkey="http://namespaces.plone.org/monkey" | ||
i18n_domain="ftw.copymovepatches"> | ||
|
||
<monkey:patch | ||
description="Backport dexterity copy flags" | ||
class="plone.dexterity.content.PasteBehaviourMixin" | ||
original="_getCopy" | ||
replacement=".dx_copy_flags.PasteBehaviourMixin_getCopy" | ||
ignoreOriginal="True" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from plone.dexterity.content import PasteBehaviourMixin | ||
|
||
|
||
# Patch for plone.dexterity.content.PasteBehaviourMixin._getCopy | ||
def PasteBehaviourMixin_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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from ftw.builder import builder_registry | ||
from ftw.builder.dexterity import DexterityBuilder | ||
|
||
|
||
class DXContainerBuilder(DexterityBuilder): | ||
portal_type = 'DXContainer' | ||
|
||
|
||
builder_registry.register('dx container', DXContainerBuilder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<configure | ||
xmlns="http://namespaces.zope.org/zope" | ||
xmlns:genericsetup="http://namespaces.zope.org/genericsetup" | ||
xmlns:i18n="http://namespaces.zope.org/i18n" | ||
i18n_domain="ftw.copymovepatches"> | ||
|
||
<genericsetup:registerProfile | ||
title="ftw.copymovepatches.tests" | ||
name="default" | ||
directory="profiles/default" | ||
provides="Products.GenericSetup.interfaces.EXTENSION" | ||
/> | ||
|
||
</configure> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0"?> | ||
<object name="portal_types" meta_type="Plone Types Tool"> | ||
<object name="DXContainer" meta_type="Dexterity FTI"/> | ||
</object> |
16 changes: 16 additions & 0 deletions
16
ftw/copymovepatches/tests/profiles/default/types/DXContainer.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0"?> | ||
<object name="DXContainer" | ||
meta_type="Dexterity FTI" | ||
xmlns:i18n="http://xml.zope.org/namespaces/i18n" | ||
i18n:domain="ftw.copymovepatches"> | ||
|
||
<property name="title">DXContainer</property> | ||
<property name="global_allow">True</property> | ||
<property name="filter_content_types">False</property> | ||
<property name="klass">plone.dexterity.content.Container</property> | ||
<property name="behaviors"> | ||
<element value="plone.app.dexterity.behaviors.metadata.IBasic" /> | ||
<element value="plone.app.content.interfaces.INameFromTitle" /> | ||
</property> | ||
|
||
</object> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from ftw.builder import Builder | ||
from ftw.builder import create | ||
from ftw.copymovepatches.tests import FunctionalTestCase | ||
|
||
|
||
class TestDexterityCopyFlags(FunctionalTestCase): | ||
|
||
def test_copy_flags_are_set_on_copy(self): | ||
self.grant('Manager') | ||
container_ori = create(Builder('dx container')) | ||
clipboard = self.portal.manage_copyObjects([container_ori.id]) | ||
self.portal.manage_pasteObjects(clipboard) | ||
container_copy = self.portal.get('copy_of_' + container_ori.id) | ||
self.assertEquals(1, getattr(container_copy, '_v_is_cp', None)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters