Question

I'm writing an add-view adapter and want to restrict its use to a specific permission.

In ZCML I can do the following:

<class class=".add.AddView">
    <require
        permission="cmf.AddPortalContent"
        interface="zope.publisher.interfaces.browser.IBrowserPage"
        />
</class>

Is there a grok equivalent way of doing this?

Simply using grok.require doesn't work.

My adapter looks like this:

class AddForm(grok.MultiAdapter, add.AddView):
    grok.adapts(IFolderish, IThemeSpecific, IDynamicViewTypeInformation)
    grok.name('addATDocument')
    grok.provides(IBrowserPage)
    grok.require('cmf.AddPortalContent')

But without the ZCML snippet, I can anonymously render the add view.

Was it helpful?

Solution

You could try using the package grokcore.security 1.5

http://pypi.python.org/pypi/grokcore.security#defining-permissions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top