Skip to content

Commit 259d969

Browse files
wesleybldavisagli
andauthoredJan 28, 2025··
Allows working copy of the Portal (#1823)
* Allows working copy of the Portal Allows working copy services to be accessed in the Portal. Also returns working copy data in the Portal serialization. * Add Changes * Does not return working copy information when serializing Portal in Plone 5.2 * better check for working copy support: test for feature instead of testing for version * Update news/1823.feature --------- Co-authored-by: David Glick <david@glicksoftware.com>
1 parent 0a2f821 commit 259d969

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed
 

‎news/1823.feature

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support working copies of the Plone Site. This feature is available when using `plone.app.iterate` 6.1.0 or later. @wesleybl

‎src/plone/restapi/serializer/dxcontent.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,19 @@
4242
WorkingCopyInfo = None
4343

4444

45+
def update_with_working_copy_info(context, result):
46+
if WorkingCopyInfo is None:
47+
return
48+
49+
working_copy_info = WorkingCopyInfo(context)
50+
try:
51+
baseline, working_copy = working_copy_info.get_working_copy_info()
52+
except TypeError:
53+
# not supported for this content type
54+
return
55+
result.update({"working_copy": working_copy, "working_copy_of": baseline})
56+
57+
4558
def get_allow_discussion_value(context, request, result):
4659
# This test is to handle the situation of plone.app.discussion not being installed
4760
# or not being activated.
@@ -108,11 +121,7 @@ def __call__(self, version=None, include_items=True):
108121
result.update({"previous_item": {}, "next_item": {}})
109122

110123
# Insert working copy information
111-
if WorkingCopyInfo is not None:
112-
baseline, working_copy = WorkingCopyInfo(
113-
self.context
114-
).get_working_copy_info()
115-
result.update({"working_copy": working_copy, "working_copy_of": baseline})
124+
update_with_working_copy_info(self.context, result)
116125

117126
# Insert locking information
118127
result.update({"lock": lock_info(obj)})

‎src/plone/restapi/serializer/site.py

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from plone.restapi.interfaces import ISerializeToJsonSummary
1313
from plone.restapi.serializer.converters import json_compatible
1414
from plone.restapi.serializer.dxcontent import get_allow_discussion_value
15+
from plone.restapi.serializer.dxcontent import update_with_working_copy_info
1516
from plone.restapi.serializer.expansion import expandable_elements
1617
from plone.restapi.serializer.utils import get_portal_type_title
1718
from plone.restapi.services.locking import lock_info
@@ -26,6 +27,7 @@
2627
from zope.schema import getFields
2728
from zope.security.interfaces import IPermission
2829

30+
2931
import json
3032

3133

@@ -74,6 +76,9 @@ def __call__(self, version=None):
7476
"description": self.context.description,
7577
}
7678

79+
# Insert working copy information
80+
update_with_working_copy_info(self.context, result)
81+
7782
if HAS_PLONE_6:
7883
result["UID"] = self.context.UID()
7984
# Insert review_state

‎src/plone/restapi/services/workingcopy/configure.zcml

+33
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,37 @@
3939
name="@workingcopy"
4040
/>
4141

42+
<plone:service
43+
method="GET"
44+
factory=".get.GetWorkingCopy"
45+
for="Products.CMFCore.interfaces.ISiteRoot"
46+
permission="zope2.View"
47+
name="@workingcopy"
48+
/>
49+
50+
<plone:service
51+
method="POST"
52+
factory=".create.CreateWorkingCopy"
53+
for="Products.CMFCore.interfaces.ISiteRoot"
54+
permission="plone.app.iterate.CheckOutContent"
55+
name="@workingcopy"
56+
/>
57+
58+
59+
<plone:service
60+
method="PATCH"
61+
factory=".update.UpdateWorkingCopy"
62+
for="Products.CMFCore.interfaces.ISiteRoot"
63+
permission="plone.app.iterate.CheckInContent"
64+
name="@workingcopy"
65+
/>
66+
67+
<plone:service
68+
method="DELETE"
69+
factory=".delete.DeleteWorkingCopy"
70+
for="Products.CMFCore.interfaces.ISiteRoot"
71+
permission="zope2.DeleteObjects"
72+
name="@workingcopy"
73+
/>
74+
4275
</configure>

0 commit comments

Comments
 (0)
Please sign in to comment.