Skip to content

Commit

Permalink
refactor: do not hard import IPortletAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Feb 14, 2025
1 parent ecc6491 commit 9453d27
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/plone/restapi/services/history/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
from zope.component import queryMultiAdapter
from zope.component.hooks import getSite
from zope.interface import implementer, alsoProvides
from plone.portlets.interfaces import IPortletAssignment
from zope.publisher.interfaces import IPublishTraverse

try:
from plone.portlets.interfaces import IPortletAssignment
except ImportError:
IPortletAssignment = None


@implementer(IPublishTraverse)
class HistoryGet(Service):
Expand All @@ -28,7 +32,10 @@ def reply(self):
# Traverse to historical version
if self.version:
parent = aq_parent(aq_inner(self.context))
if not IPortletAssignment.providedBy(parent):
if (
IPortletAssignment is not None
and not IPortletAssignment.providedBy(parent)
):
alsoProvides(parent, IPortletAssignment)
serializer = queryMultiAdapter(
(self.context, self.request), ISerializeToJson
Expand Down

0 comments on commit 9453d27

Please sign in to comment.