我想重新定义stock folder_contents浏览器View的安全性,以便只有具有Reviewer角色的成员才能访问它。
该类在plone.app.content.browser.foldercontents.FolderContentsView中定义
在我的custom.policy产品中,我有
浏览器/ 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>
浏览器中的/ overrides.py
from plone.app.content.browser.foldercontents import FolderContentsView
class ProtectedFolderContentsView(FolderContentsView):
""" Customized FolderContentsView """
然而,当我启动实例时,我得到:
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" />
如何在遇到冲突时完成此覆盖?
答案 0 :(得分:5)
如果这只是自定义网站配置而不是你将构建的东西,那么这正是overrides.zcml的用途。创建自定义/ policy / overrides.zcml:
<configure xmlns="http://namespaces.zope.org/zope">
<include package=".browser" file="overrides.zcml" />
</configure>
然后将您的browser / configure.zcml重命名为browser / overrides.zcml。
答案 1 :(得分:3)
您是否尝试过指定自定义浏览器图层?
答案 2 :(得分:2)
将其注册为更具体的界面。比如说zope.interface.Interface或Products.Archetypes.interfaces.IBaseContent。