Grok equivalent for the ZCML "require" directive
I am writing an add-view adapter and want to restrict its use to a specific resolution.
In ZCML, I can do the following:
<class class=".add.AddView">
<require
permission="cmf.AddPortalContent"
interface="zope.publisher.interfaces.browser.IBrowserPage"
/>
</class>
Is there an equivalent way to do this?
Just 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 display the add view anonymously.
+3
source to share
1 answer
You can try using grokcore.security 1.5 package
http://pypi.python.org/pypi/grokcore.security#defining-permissions
+2
source to share