http://developer.plone.org/reference_manuals/external/plone.app.dexterity/advanced/permissions.html
In the documentation, I see this,
Note All permissions need to be defined before the line in configure.zcml. Otherwise, you may get errors trying to use the permission with a grok.require() directive. The
permissions.zcml
file looks like this:<configure xmlns="http://namespaces.zope.org/zope" i18n_domain="example.conference"> <permission id="example.conference.AddSession" title="example.conference: Add session" /> <permission id="example.conference.ModifyTrack" title="example.conference: Modify track" /> </configure>
New permissions are granted to the Manager role only by default. To set a different default, we can use the rolemap.xml GenericSetup import step, which maps permissions to roles at the site root.
In
profiles/default/rolemap.xml
, we have the following:<?xml version="1.0"?> <rolemap> <permissions> <permission name="example.conference: Add session" acquire="True"> <role name="Owner"/> <role name="Manager"/> <role name="Member"/> <role name="Contributor"/> </permission> <permission name="example.conference: Modify track" acquire="True"> <role name="Manager"/> <role name="Reviewer"/> </permission> </permissions> </rolemap>
Note This file uses the Zope 2 permission title instead of the shorter Zope 3 permission id."
Can Plone's Dexterity be programmed to use a database? What if I had thousands of users? That's a lot of xml files to keep up with, when I have it in Active Directory already, or a MySQL database. I want to keep buttons and other webpage items from being displayed based upon their security. Dexterity appears to do that.
Thanks.
EDIT: Thank you for clearing up my confusion between users and roles, as the users are kept in a repository like an LDAP server.
Am I correct that after I have my roles and users set up that all I have to do is wrap my html thusly (after defining the Python code as below):
"As an example, let’s display a message on the view of a Session type if the user has the cmf.RequestReview permission. In session.py, we update the View class with the following (same page),
from zope.security import checkPermission
class View(dexterity.DisplayForm):
grok.context(ISession)
grok.require('zope2.View')
def canRequestReview(self):
return checkPermission('cmf.RequestReview', self.context)
And in the session_templates/view.pt template, we add:
<div class="discreet"
tal:condition="view/canRequestReview"
i18n:translate="suggest_review">
Please submit this for review.
</div>
"