Skip to main content

Replicating Sharing Feature of Plone

Today, for my project I had to replicate Sharing Feature for my Project Management Product.
My Client liked the UI of the Plone sharing very much. This is one of the features of Plone 3 that I liked.
So I started to write this feature for my product. I wanted to show only three roles and members having any of these 3 roles only. I was not interested in remaining roles the user had as those roles won't affect my workflow. I copied sharing.py sharing.pt macro_renderer.pt, kss_sharing.py files from plone.app.workflow's browser folder. Then I copied the configurartion of sharing and kss view from configuration.zcml. I readjusted the names for browser page to suit my needs. I restarted zope and voila! my custom sharing page was ready.
To show only required 3 roles, I went and edited def roles(self) to show only required 3 roles

def roles(self):
"""Get a list of roles that can be managed.
Returns a list of dicts with keys:
- id
- title
"""
context = aq_inner(self.context)
portal_membership = getToolByName(context, 'portal_membership')
pairs = []
for name, utility in getUtilitiesFor(ISharingPageRole):
permission = utility.required_permission
if permission is None or portal_membership.checkPermission(permission, context):
if name in ['Role1','Role2','Role3']:
pairs.append(dict(id = name, title = utility.title))
pairs.sort(key=lambda x: x["id"])
return pairs

This gave me the required result. Next I had to work on updating the table on search. This was difficult to me as I was bit new to kss. I had not used Kss till now. Changed the the Kss view based on this tutorial Simple Scripting with Kss, I added kss file and registered it. That it. My Sharing like form started working.

P.S I don't know if the procedure for replicating Sharing like feature is right or wrong. For now, My client is happy with it.

Comments