Skip to content

Commit

Permalink
Merge pull request #11 from IMIO/WEB-4153
Browse files Browse the repository at this point in the history
feat: override @vocabularies endpoint to add a cache ruleset on it
  • Loading branch information
remdub authored Jan 9, 2025
2 parents a3d21c0 + 0d38f70 commit f87c6ac
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.2.19 (unreleased)
-------------------

- Nothing changed yet.
- WEB-4153 : Override @vocabularies endpoint to add a cache ruleset on it
[remdub]


1.2.18 (2024-07-01)
Expand Down
2 changes: 2 additions & 0 deletions src/imio/smartweb/common/rest/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
xmlns="http://namespaces.zope.org/zope"
xmlns:plone="http://namespaces.plone.org/plone">

<include package=".vocabularies" />

<plone:service
method="GET"
for="zope.interface.Interface"
Expand Down
Empty file.
35 changes: 35 additions & 0 deletions src/imio/smartweb/common/rest/vocabularies/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:cache="http://namespaces.zope.org/cache"
xmlns:plone="http://namespaces.plone.org/plone"
xmlns:zcml="http://namespaces.zope.org/zcml"
i18n_domain="imio.smartweb">

<plone:service
name="@vocabularies"
method="GET"
accept="application/json"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
factory=".endpoint.VocabulariesGet"
permission="zope2.View"
layer="imio.smartweb.common.interfaces.IImioSmartwebCommonLayer"
/>

<plone:service
name="@vocabularies"
method="GET"
accept="application/json"
for="Products.CMFCore.interfaces.IContentish"
factory=".endpoint.VocabulariesGet"
permission="zope2.View"
layer="imio.smartweb.common.interfaces.IImioSmartwebCommonLayer"
/>

<cache:ruleset
for=".endpoint.VocabulariesGet"
ruleset="plone.stableResource"
zcml:condition="have plone-app-caching-3"
/>

</configure>
10 changes: 10 additions & 0 deletions src/imio/smartweb/common/rest/vocabularies/endpoint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# -*- coding: utf-8 -*-

from plone.restapi.services.vocabularies.get import (
VocabulariesGet as BaseVocabulariesGet,
)


class VocabulariesGet(BaseVocabulariesGet):
def reply(self):
return super(VocabulariesGet, self).reply()

0 comments on commit f87c6ac

Please sign in to comment.