Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allows versioning of the Plone Site type for the portal working copy to work #113

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Products/CMFEditions/StandardModifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Products/CMFEditions/profiles/default/repositorytool.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@
<policy name="at_edit_autoversion" />
<policy name="version_on_revert" />
</type>
<type name="Plone Site">
<policy name="at_edit_autoversion" />
<policy name="version_on_revert" />
</type>
Comment on lines +29 to +32
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure whether I should do an upgrade step for this or just leave it for new portals.

</policymap>
</repositorytool>
24 changes: 24 additions & 0 deletions Products/CMFEditions/tests/test_ContentTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions news/113.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Allows versioning of the Plone Site type for the portal working copy to work. @wesleybl