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

fix: plone.restapi must work with dependency on only Products.CMFPlone #1461

Merged
merged 2 commits into from
Aug 5, 2022
Merged
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
2 changes: 2 additions & 0 deletions news/1461.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Do not hard depend on `plone.app.iterate`. It is not an direct core package and might not be available.
[jensens]
15 changes: 12 additions & 3 deletions src/plone/restapi/serializer/dxcontent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from plone.restapi.serializer.converters import json_compatible
from plone.restapi.serializer.expansion import expandable_elements
from plone.restapi.serializer.nextprev import NextPrevious
from plone.restapi.serializer.working_copy import WorkingCopyInfo
from plone.restapi.services.locking import lock_info
from plone.rfc822.interfaces import IPrimaryFieldInfo
from plone.supermodel.utils import mergedTaggedValueDict
Expand All @@ -30,6 +29,13 @@
from zope.schema import getFields
from zope.security.interfaces import IPermission

try:
# plone.app.iterate is by intend not part of Products.CMFPlone dependencies
# so we can not rely on having it
from plone.restapi.serializer.working_copy import WorkingCopyInfo
except ImportError:
WorkingCopyInfo = None


@implementer(ISerializeToJson)
@adapter(IDexterityContent, Interface)
Expand Down Expand Up @@ -77,8 +83,11 @@ def __call__(self, version=None, include_items=True):
)

# Insert working copy information
baseline, working_copy = WorkingCopyInfo(self.context).get_working_copy_info()
result.update({"working_copy": working_copy, "working_copy_of": baseline})
if WorkingCopyInfo is not None:
baseline, working_copy = WorkingCopyInfo(
self.context
).get_working_copy_info()
result.update({"working_copy": working_copy, "working_copy_of": baseline})

# Insert locking information
result.update({"lock": lock_info(obj)})
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/services/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<include package=".workflow" />
<include
package=".workingcopy"
zcml:condition="have plone-5"
zcml:condition="installed plone.app.iterate"
/>
<include
package=".multilingual"
Expand Down