plone / Products.CMFPlone

The core of the Plone content management system
https://plone.org
GNU General Public License v2.0
254 stars 191 forks source link

Relations lost in folderish working copies #2384

Closed tomgross closed 6 years ago

tomgross commented 6 years ago

What I did:

I'm using Plone with plone.app.iterate and collective.folderishtypes. With folderish standardtypes Plone faces some special challenges.

Plone.app.iterate is "borrowing" code from "z3c.relationfield" to handle relations between the baseline and the working copy.

Z3c.relationfield provides an event subscriber binding to zope.lifecycleevent.IObjectModifiedEvent. This subscriber removes ALL references https://github.com/zopefoundation/z3c.relationfield/blob/ff23d32cf95a6069878bff05a969dc4686d240ea/src/z3c/relationfield/event.py#L76

and creates new ones afterwards. Now the problem is that adding only considers relations coming from a schema field which plone.app.iterate relations do not. This leads to the following situation

What I expect to happen:

A working copy from /a/b is created

What actually happened:

The relation between /a and /copy_of_a (working copy) is lost

What version of Plone/ Addons I am using:

tomgross commented 6 years ago

A Test for this is:

    def test_working_sub_copy(self):
        wc1_policy = ICheckinCheckoutPolicy(self.a)
        wc1 = wc1_policy.checkout(self.base)
        wc_obj = wc1_policy.getWorkingCopy()

        wc2_policy = ICheckinCheckoutPolicy(self.b)
        wc2 = wc2_policy.checkout(self.layer1)
        # test wc1 stays even, if a child creates a working copy
        self.assertEqual(wc1_policy.getWorkingCopy(), wc_obj)
tomgross commented 6 years ago

Fixed with z3c.relationfield PR.