Redefining security for a browser view in Plone 4 - 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?

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.

Related

"external_login_url" customize Plone-login-form

I need to customize Plone login form without make changes in plone original login-form https://github.com/plone/Products.CMFPlone/blob/master/Products/CMFPlone/skins/plone_login/login_form.cpt so there are two ways first i use override.zcml to change login-form :
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class="Products.CMFPlone.browser.admin.RootLoginRedirect"
permission="cmf.ManagePortal"
template="templates/login.pt"
/>
and another a simple login.pt file.It generating an Trace:
File "/Plone/buildout-cache/eggs/Products.CMFPlone-4.3.3-py2.7.egg/Products/CMFPlone/browser/admin.zcml", line 43.2-48.8
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class=".admin.RootLoginRedirect"
permission="cmf.ManagePortal"
/>
File "/Plone/buildout-cache/eggs/my_app.egg/my/app/browser/overrides.zcml", line 7.4-12.10
<browser:page
for="OFS.interfaces.IApplication"
name="plone-root-login"
class=".admin.RootLoginRedirect"
permission="cmf.ManagePortal"
/>
And Second Method: external_login_url in default/propertiesTool.xml i tried but changes not reflected

Customize Plone view class without touching the template

If a view is registered like this, with the template definition in zcml:
<browser:page
name="original-view"
class=".original_view.View"
permission="zope2.View"
for="*"
template="original_template.pt"
/>
and i want to customize only his class in my product, is there a way to do it without customizing also the template?
You have to wrap the browser:page by <configure package='XXXX'>
That means your then in scope of this packge.
Example:
<configure package="original.package.browser">
<!-- custom view -->
<browser:page
name="original-view"
class="your.package.browser.View" <!-- Full dotted name to you custom view class -->
permission="zope2.View"
for="*"
layer="your.package.interfaces.IYourPackageLayer" <!-- You should provide a browserlayer, otherwise you got a configuration conflict -->
template="original_template.pt" <!-- template from original.package.browser -->
/>
</configure>
EDIT:
As #sdupton mentioned, I updated the example code snipped with a layer
If you can't use a layer (BrowserLayer) you can put the code, without layer attribute into a overrides.zcml
You can also specify a more precise Interface in the for attribute

Hide default properties and show aspect properties on Share

I'm stuck and I cannot figure out why can achieve this. I'm new to Alfresco, so maybe I'm doing it in a wrong way.
I'm trying to hide default properties on Alfresco Share and only show fields of one of my custom aspects. I mean I want to hide cm:title, cm:name etc.
I'm trying to carry out this by customizing share-config-custom.xml. If I only use <hide> with default properties (without adding custom fields) these are correctly hidden. If I use <show> with my custom properties, both, custom properties and default properties are shown. But the problem is that if I add <hide> and <show> fields, only default fields are shown, although they are seted as hidden.
Here is an example XML:
<config evaluator="node-type" condition="cm:content">
<forms>
<form>
<field-visibility>
<hide id="cm:title" />
<hide id="cm:description" />
<show id="custom:DocumentClass" />
<show id="custom:DocumentDate" />
</field-visibility>
</form>
</forms>
</config>
Thaks in advance.
You can try the following:
Use the hide fields on the cm:content type
Add an extra config and instead of the evaluator="node-type" make it evaluator="aspect"
Add your custom aspect in the new config you just created
If the above doesn't work, try adding replace=true flag to the cm:content config

How to move the documentactions viewlet from a viewletmanager to another?

Once again back with a Plone question.
I have Plone 4 installed and I need to show the Document action icons at the top instead of bottom. having trouble in getting this to work. can someone help.
If you just need to move that viewlet (with same class and template), first you have to register a viewlet with same class to your desired viewletmanager (let's say for ex. plone.app.layout.viewlets.interfaces.IAboveContentBody):
<browser:viewlet
name="plone.abovecontenttitle.documentactions"
manager="plone.app.layout.viewlets.interfaces.IAboveContentBody"
class="plone.app.layout.viewlets.content.DocumentActionsViewlet"
permission="zope2.View"
/>
and then add this in your genericsetup profile (file viewlets.xml) :
<?xml version="1.0"?>
<object>
<order manager="plone.abovecontentbody" skinname="Plone Default">
<!-- this will place your viewlet before all the others.
you can also use a viewlet's name for a relative position -->
<viewlet name="plone.abovecontenttitle.documentactions" insert-before="*"/>
</order>
<hidden manager="plone.belowcontentbody" skinname="Plone Default">
<viewlet name="plone.abovecontenttitle.documentactions"/>
</hidden>
</object>
More info:
http://plone.org/documentation/kb/customization-for-developers/viewlets
http://collective-docs.readthedocs.org/en/latest/views/viewlets.html

How do I register a marker interface so it is visible in Plones's ZMI?

I would like to register a marker interface so I can add it to objects in the ZMI. My product's configure.zcml contains:
<interface interface=".interfaces.IMarkerInterface" />
and, after reinstalling, the interface shows up in the list of available interfaces. But if I try to add it to an object in the ZMI I get a ComponentLookupError. What's missing?
It worked Ok for me.
I tested it in Plone 4.0.3
Created a package with paster:
paster create -t plone bogus.interface
With this interfaces.py file:
from zope.interface import Interface
class IBogusInterface(Interface):
""" Marker bogus interface
"""
And this configure.zcml file:
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:five="http://namespaces.zope.org/five"
xmlns:i18n="http://namespaces.zope.org/i18n"
i18n_domain="bogus.interface">
<five:registerPackage package="." initialize=".initialize" />
<!-- -*- extra stuff goes here -*- -->
<interface interface=".interfaces.IBogusInterface" />
</configure>
Are you sure you weren't missing anything?
Also note that apparently, marker interfaces must be empty. They cannot contain attributes or methods - if they do, they won't show up in the ZMI.

Resources