Redefining security for a browser view in Plone 4
I'd like to redefine security for the stock folder_contents browser View so that only members with the Reviewer role have access to it.
The class is defined in plone.app.content.browser.foldercontents.FolderContentsView
In my custom.policy product, I have
browser/configure.zcml:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
i18n_domain="custom.policy">
<browser:page
for="*"
class=".overrides.FolderContentsView"
name="folder_contents"开发者_如何学运维
template="folder_contents.pt"
permission="cmf.ReviewPortalContent"
/>
</configure>
in browser/overrides.py
from plone.app.content.browser.foldercontents import FolderContentsView
class ProtectedFolderContentsView(FolderContentsView):
""" Customized FolderContentsView """
However, when I start the instance, I get:
zope.configuration.config.ConfigurationConflictError: Conflicting configuration actions
For: ('view', None, u'folder_contents', <InterfaceClass zope.publisher.interfaces.browser.IBrowserRequest>, <InterfaceClass zope.publisher.interfaces.browser.IDefaultBrowserLayer>)
File "src/custom.policy/custom/policy/browser/configure.zcml", line 30.2-36.6
<browser:page
for="*"
class=".overrides.FolderContentsView"
name="folder_contents"
template="folder_contents.pt"
permission="cmf.ReviewPortalContent"
/>
File "eggs/plone.app.content-2.0.7-py2.6.egg/plone/app/content/browser/configure.zcml", line 15.4-20.46
<browser:page
for="*"
class=".foldercontents.FolderContentsView"
name="folder_contents"
template="folder_contents.pt"
permission="cmf.ListFolderContents" />
How can I accomplish this override with running into conflicts?
If this really is just custom site configuration and not something you'll ever build on top of, then that's exactly what overrides.zcml is for. Create an custom/policy/overrides.zcml:
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".browser" file="overrides.zcml" />
</configure>
Then rename your browser/configure.zcml to browser/overrides.zcml.
have you tried by specifying a custom browser layer?
Register it for a more specific interface. Say zope.interface.Interface, or Products.Archetypes.interfaces.IBaseContent instead.
精彩评论