Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redefining security for a browser view in Plone 4

Tags:

zope

plone

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?

like image 353
Rigel Di Scala Avatar asked Dec 28 '22 16:12

Rigel Di Scala


2 Answers

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.

like image 115
Ross Patterson Avatar answered Jan 31 '23 10:01

Ross Patterson


have you tried by specifying a custom browser layer?

like image 36
simahawk Avatar answered Jan 31 '23 08:01

simahawk