From 5faa0437d64328e1f9161dc4859fb9429ab78c1a Mon Sep 17 00:00:00 2001 From: wesleybl Date: Wed, 2 Oct 2024 16:44:51 -0300 Subject: [PATCH 1/3] Allows versioning of the "Plone Site" type For the working copy of plone.app.iterate to work on the "Plone Site" type, it is necessary that this type is versionable. See: https://github.com/plone/plone.app.iterate/blob/1908aa1f4e9c95c37143fae88655469b72ea451a/plone/app/iterate/browser/control.py#L88-L90 --- .../profiles/default/repositorytool.xml | 4 ++++ .../CMFEditions/tests/test_ContentTypes.py | 24 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Products/CMFEditions/profiles/default/repositorytool.xml b/Products/CMFEditions/profiles/default/repositorytool.xml index 08130c9..644d381 100644 --- a/Products/CMFEditions/profiles/default/repositorytool.xml +++ b/Products/CMFEditions/profiles/default/repositorytool.xml @@ -26,5 +26,9 @@ + + + + diff --git a/Products/CMFEditions/tests/test_ContentTypes.py b/Products/CMFEditions/tests/test_ContentTypes.py index c0e05c1..530f943 100644 --- a/Products/CMFEditions/tests/test_ContentTypes.py +++ b/Products/CMFEditions/tests/test_ContentTypes.py @@ -105,6 +105,30 @@ def testNewsItem(self): self.assertEqual(content.text.raw, "text v1") self.metadata_test_one(content) + def test_plone_site(self): + portal_repository = self.portal_repository + content = self.portal + content.title = "content" + content.subject = ["content"] + content.description = "content" + content.contributors = ["content"] + content.language = "content" + content.rights = "content" + portal_repository.applyVersionControl(content, comment="save no 1") + content.title = "contentOK" + content.subject = ["contentOK"] + content.description = "contentOK" + content.contributors = ["contentOK"] + content.language = "contentOK" + content.rights = "contentOK" + portal_repository.save(content, comment="save no 2") + obj = portal_repository.retrieve(content, 0).object + self.metadata_test_one(obj) + obj = portal_repository.retrieve(content, 1).object + self.metadata_test_two(obj) + portal_repository.revert(content, 0) + self.metadata_test_one(content) + def testImage(self): self.folder.invokeFactory("Image", id="image") portal_repository = self.portal_repository From 9753c817c83350d2dd2f3e85a9d4bb89997a350e Mon Sep 17 00:00:00 2001 From: wesleybl Date: Wed, 2 Oct 2024 17:00:44 -0300 Subject: [PATCH 2/3] Allows the "Plone Site" type to be cloned Products.CMFEditions uses the pickle module to clone objects. See: https://github.com/plone/Products.CMFEditions/blob/c80bc31af46bff45fee2908878b1f01190fda8d8/Products/CMFEditions/ArchivistTool.py#L210-L229 These changes prevent the error: TypeError: Can't pickle objects in acquisition wrappers When trying to serialize an ImplicitAcquisitionWrapper object with the pickle dump. This error occurred when trying to check in a Plone Site type with plone.app.iterate. These changes also allow the Plone Site type to be serialized with the pickle. --- Products/CMFEditions/StandardModifiers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Products/CMFEditions/StandardModifiers.py b/Products/CMFEditions/StandardModifiers.py index 50d03a0..23f05a6 100644 --- a/Products/CMFEditions/StandardModifiers.py +++ b/Products/CMFEditions/StandardModifiers.py @@ -26,6 +26,7 @@ from AccessControl.class_init import InitializeClass from Acquisition import aq_base +from Acquisition import ImplicitAcquisitionWrapper from OFS.ObjectManager import ObjectManager from plone.folder.default import DefaultOrdering from Products.BTreeFolder2.BTreeFolder2 import BTreeFolder2Base @@ -673,6 +674,15 @@ def getOnCloneModifiers(self, obj): parent_id = id(aq_base(parent)) def persistent_id(obj): + # Avoid: TypeError: Can't pickle objects in acquisition wrappers. + if isinstance(obj, ImplicitAcquisitionWrapper): + return True + # Allows Plone Site to be serialized with pickle. + if ( + hasattr(aq_base(obj), "portal_type") + and aq_base(obj).portal_type == "Plone Site" + ): + return if id(aq_base(obj)) == parent_id: return True return None From de7f30c60711a27a3dca5e0b171bcdcc5f326b43 Mon Sep 17 00:00:00 2001 From: wesleybl Date: Wed, 2 Oct 2024 17:18:58 -0300 Subject: [PATCH 3/3] Add changes --- news/113.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/113.feature diff --git a/news/113.feature b/news/113.feature new file mode 100644 index 0000000..1513873 --- /dev/null +++ b/news/113.feature @@ -0,0 +1 @@ +Allows versioning of the Plone Site type for the portal working copy to work. @wesleybl