Skip to content

Commit

Permalink
adapt for Plone 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
erral committed Oct 17, 2023
1 parent 063b164 commit dfb352d
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions src/plone/restapi/services/site/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@
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
from zope.component import getUtility
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)
Expand All @@ -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,
}
)
Expand Down

0 comments on commit dfb352d

Please sign in to comment.