Back to index

plone3  3.1.7
setuphandlers.py
Go to the documentation of this file.
00001 """
00002 PlonePAS setup handlers.
00003 """
00004 
00005 from StringIO import StringIO
00006 
00007 from Products.CMFCore.utils import getToolByName
00008 from Products.CMFPlone.migrations.v2_5.two51_two52 import \
00009     setLoginFormInCookieAuth
00010 
00011 from Products.PlonePAS.Extensions.Install import challenge_chooser_setup
00012 from Products.PlonePAS.Extensions.Install import migrate_root_uf
00013 from Products.PlonePAS.Extensions.Install import registerPluginTypes
00014 from Products.PlonePAS.Extensions.Install import setupPlugins
00015 
00016 
00017 def addRolesToPlugIn(p):
00018     """
00019     XXX This is horrible.. need to switch PlonePAS to a GenericSetup
00020     based install so this doesn't need to happen.
00021 
00022     Have to manually register the roles from the 'rolemap' step
00023     with the roles plug-in.
00024     """
00025     uf = getToolByName(p, 'acl_users')
00026     rmanager = uf.portal_role_manager
00027     roles = ('Reviewer', 'Member')
00028     existing = rmanager.listRoleIds()
00029     for role in roles:
00030         if role not in existing:
00031             rmanager.addRole(role)
00032 
00033 
00034 def setupGroups(p):
00035     """
00036     Create Plone's default set of groups.
00037     """
00038     gtool = getToolByName(p, 'portal_groups')
00039     existing = gtool.listGroupIds()
00040     if 'Administrators' not in existing:
00041         gtool.addGroup('Administrators', roles=['Manager'])
00042     if 'Reviewers' not in existing:
00043         gtool.addGroup('Reviewers', roles=['Reviewer'])
00044 
00045 
00046 def installPAS(portal):
00047     out = StringIO()
00048     
00049     # Add user folder
00050     portal.manage_addProduct['PluggableAuthService'].addPluggableAuthService()
00051 
00052     # Configure Challenge Chooser plugin if available
00053     challenge_chooser_setup(portal, out)
00054 
00055     # A bunch of general configuration settings
00056     registerPluginTypes(portal.acl_users)
00057     setupPlugins(portal, out)
00058 
00059     # TODO: This is highly questionable behaviour. Replacing the UF at the root.
00060     migrate_root_uf(portal, out)
00061 
00062 
00063 def setupPlonePAS(context):
00064     """
00065     Setup PlonePAS step.
00066     """
00067     # Only run step if a flag file is present (e.g. not an extension profile)
00068     if context.readDataFile('plone-pas.txt') is None:
00069         return
00070     out = []
00071     site = context.getSite()
00072     installPAS(site)
00073     addRolesToPlugIn(site)
00074     setupGroups(site)
00075 
00076     setLoginFormInCookieAuth(site, out)