Back to index

plone3  3.1.7
utils.py
Go to the documentation of this file.
00001 from StringIO import StringIO
00002 
00003 from Products.CMFCore.utils import getToolByName
00004 from Products.PlonePAS.Extensions.Install import activatePluginInterfaces
00005 
00006 from borg.localrole.config import LOCALROLE_PLUGIN_NAME
00007 from borg.localrole.workspace import manage_addWorkspaceLocalRoleManager
00008 
00009 def setup_localrole_plugin(portal):
00010     """Install and prioritize the local-role PAS plug-in
00011     """
00012     out = StringIO()
00013     
00014     uf = getToolByName(portal, 'acl_users')
00015 
00016     existing = uf.objectIds()
00017 
00018     if LOCALROLE_PLUGIN_NAME not in existing:
00019         manage_addWorkspaceLocalRoleManager(uf, LOCALROLE_PLUGIN_NAME)
00020         activatePluginInterfaces(portal, LOCALROLE_PLUGIN_NAME, out)
00021     else:
00022         print >> out, "%s already installed" % LOCALROLE_PLUGIN_NAME
00023         
00024     return out.getvalue()