重新定义 Plone 4 中浏览器视图的安全性

发布于 2024-11-28 01:52:30 字数 1771 浏览 2 评论 0原文

我想重新定义 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撩起发的微风 2024-12-05 01:52:30

如果这确实只是自定义站点配置,而不是您将在其上构建的东西,那么这正是 overrides.zcml 的用途。创建 custom/policy/overrides.zcml:

<configure xmlns="http://namespaces.zope.org/zope">
  <include package=".browser" file="overrides.zcml" />
</configure>

然后将 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:

<configure xmlns="http://namespaces.zope.org/zope">
  <include package=".browser" file="overrides.zcml" />
</configure>

Then rename your browser/configure.zcml to browser/overrides.zcml.

只想待在家 2024-12-05 01:52:30

您是否尝试过指定自定义浏览器层?

have you tried by specifying a custom browser layer?

一城柳絮吹成雪 2024-12-05 01:52:30

注册它以获得更具体的接口。请改用 zope.interface.Interface 或 Products.Archetypes.interfaces.IBaseContent。

Register it for a more specific interface. Say zope.interface.Interface, or Products.Archetypes.interfaces.IBaseContent instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文