Skip to content

Commit

Permalink
Add a way to check for backend support of version-dependent features …
Browse files Browse the repository at this point in the history
…via the site service
  • Loading branch information
davisagli committed Oct 17, 2024
1 parent b9a56e1 commit ce1acbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/plone/restapi/services/site/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from Products.CMFPlone.interfaces import IImagingSchema
from Products.CMFPlone.interfaces import ISiteSchema
from Products.CMFPlone.utils import getSiteLogo
from Products.CMFPlone.controlpanel.browser.redirects import RedirectionSet
from zope.component import adapter
from zope.component import getMultiAdapter
from zope.component import getUtility
Expand Down Expand Up @@ -49,6 +50,7 @@ def __call__(self, expand=False):
"plone.default_language": language_settings.default_language,
"plone.available_languages": language_settings.available_languages,
"plone.portal_timezone": self.plone_timezone(),
"features": self.features(),
}
)

Expand All @@ -73,6 +75,15 @@ def plone_timezone(self):

return portal_timezone

def features(self):
"""Indicates which features are supported by this site.
This can be used by a client to check for version-dependent features.
"""
result = {
"filter_aliases_by_date": hasattr(RedirectionSet, "supports_date_range_filtering"),
}
return result

class SiteGet(Service):
def reply(self):
Expand Down
3 changes: 3 additions & 0 deletions src/plone/restapi/tests/http-examples/site_get.resp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Content-Type: application/json

{
"@id": "http://localhost:55001/plone/@site",
"features": {
"filter_aliases_by_date": false
},
"plone.allowed_sizes": [
"huge 1600:65536",
"great 1200:65536",
Expand Down

0 comments on commit ce1acbe

Please sign in to comment.