重新定义 Plone 4 中浏览器视图的安全性
我想重新定义 stockfolder_contents 浏览器视图的安全性,以便只有具有审阅者角色的成员才能访问它。
该类在 plone.app.content.browser.foldercontents.FolderContentsView 中定义
在我的 custom.policy 产品中,我有
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>
在 browser/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" />
如何我完成此覆盖时会遇到冲突吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这确实只是自定义站点配置,而不是您将在其上构建的东西,那么这正是 overrides.zcml 的用途。创建 custom/policy/overrides.zcml:
然后将 browser/configure.zcml 重命名为 browser/overrides.zcml。
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:
Then rename your browser/configure.zcml to browser/overrides.zcml.
您是否尝试过指定自定义浏览器层?
have you tried by specifying a custom browser layer?
注册它以获得更具体的接口。请改用 zope.interface.Interface 或 Products.Archetypes.interfaces.IBaseContent。
Register it for a more specific interface. Say zope.interface.Interface, or Products.Archetypes.interfaces.IBaseContent instead.