Adding new roles to the Sharing Page

by Ricardo Alves last modified Feb 04, 2009 02:34 AM
Explains how to add other roles to the set of managed roles at Plone 3 sharing tab.

The new Sharing tab

Plone 3 includes a new, more usable sharing view. The page now displays local and acquired roles in the same table, but only for a set of "managed roles". By default, the following "managed roles", and respective friendly names, are available:

  • Contributor - Can add
  • Editor - Can edit
  • Reader - Can view
  • Reviewer - Can review

Note: Probably motivated by the presence of the friendly names, a common misunderstanding is that the new sharing page maps users to permissions, but it really maps users to roles.

Adding new roles

It is possible to add new managed roles. Say you want to add another role to this list ("Manager" - "Can manage"). Lets assume you have a package named mypackage. Add a module named mypackage/sharing.py with the following content:

from zope.interface import implements
from plone.app.workflow.interfaces import ISharingPageRole
from Products.CMFPlone import PloneMessageFactory as _

class ManagerRole(object):
   implements(ISharingPageRole)
   title = _(u"title_can_manage", default=u"Can manage")
   required_permission = 'Manage portal content'

The value of required_permission is the permission the user must have to be able to delegate that role. Then add the following to the file mypackage/configure.zcml:

<utility name="Manager" factory=".sharing.ManagerRole"/>

Note: These instructions are only valid for existing Zope roles. For new roles, you need to add them first, and only then add to the sharing page.

After restarting Zope, the sharing page includes the new column "Can manage".