From dfb352db088540b5b21830378b90f406c07d99d2 Mon Sep 17 00:00:00 2001 From: Mikel Larreategi Date: Tue, 17 Oct 2023 17:03:36 +0200 Subject: [PATCH] adapt for Plone 4.3 --- src/plone/restapi/services/site/get.py | 33 ++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/plone/restapi/services/site/get.py b/src/plone/restapi/services/site/get.py index a7bca37c70..f2fe3cdc8c 100644 --- a/src/plone/restapi/services/site/get.py +++ b/src/plone/restapi/services/site/get.py @@ -2,8 +2,6 @@ from plone.registry.interfaces import IRegistry from plone.restapi.interfaces import IExpandableElement from plone.restapi.services import Service -from Products.CMFPlone.interfaces import IImagingSchema -from Products.CMFPlone.interfaces import ISiteSchema from Products.CMFPlone.utils import getSiteLogo from zope.component import adapter from zope.component import getMultiAdapter @@ -11,6 +9,15 @@ from zope.interface import implementer from zope.interface import Interface +try: + from Products.CMFPlone.interfaces import IImagingSchema +except ImportError: + IImagingSchema = None +try: + from Products.CMFPlone.interfaces import ISiteSchema +except ImportError: + ISiteSchema = None + @implementer(IExpandableElement) @adapter(Interface, Interface) @@ -28,15 +35,27 @@ def __call__(self, expand=False): (self.context, self.request), name="plone_portal_state" ) registry = getUtility(IRegistry) - site_settings = registry.forInterface(ISiteSchema, prefix="plone", check=False) - image_settings = registry.forInterface( - IImagingSchema, prefix="plone", check=False + + if ISiteSchema is not None: + site_settings = registry.forInterface(ISiteSchema, prefix="plone", check=False) + result["site"].update({ + "plone.site_logo": site_settings.site_logo and getSiteLogo() or None, + "plone.robots_txt": site_settings.robots_txt, + }) + + if IImagingSchema is not None: + image_settings = registry.forInterface( + IImagingSchema, prefix="plone", check=False + ) + result["site"].update( + { + "plone.allowed_sizes": image_settings.allowed_sizes, + } ) + result["site"].update( { "plone.site_title": portal_state.portal_title(), - "plone.site_logo": site_settings.site_logo and getSiteLogo() or None, - "plone.robots_txt": site_settings.robots_txt, "plone.allowed_sizes": image_settings.allowed_sizes, } )