From: hannosch <svn...@pl...> - 2006-12-31 02:32:12
|
Author: hannosch Date: Sun Dec 31 02:32:06 2006 New Revision: 35220 Added: PlonePAS/trunk/profiles/ PlonePAS/trunk/profiles.zcml (contents, props changed) PlonePAS/trunk/profiles/default/ PlonePAS/trunk/profiles/default/import_steps.xml (contents, props changed) PlonePAS/trunk/profiles/default/plone-pas.txt (contents, props changed) PlonePAS/trunk/setuphandlers.py (contents, props changed) Modified: PlonePAS/trunk/configure.zcml Log: Started converting PlonePAS installation to be GenericSetup based. The first step is to use an extension profile and call all the methods from Extensions.Install.py. Also moved all of the user/group related setup functions from CMFPlone over here, so we have a single place to look at. We won't change the Extensions.Install code as it is still used for migrating existing sites. Modified: PlonePAS/trunk/configure.zcml ============================================================================== --- PlonePAS/trunk/configure.zcml (original) +++ PlonePAS/trunk/configure.zcml Sun Dec 31 02:32:06 2006 @@ -1,6 +1,8 @@ <configure xmlns="http://namespaces.zope.org/zope" xmlns:five="http://namespaces.zope.org/five"> + <include file="profiles.zcml"/> + <five:deprecatedManageAddDelete class=".plugins.cookie_handler.ExtendedCookieAuthHelper" /> Added: PlonePAS/trunk/profiles.zcml ============================================================================== --- (empty file) +++ PlonePAS/trunk/profiles.zcml Sun Dec 31 02:32:06 2006 @@ -0,0 +1,14 @@ +<configure + xmlns="http://namespaces.zope.org/zope" + xmlns:genericsetup="http://namespaces.zope.org/genericsetup" + i18n_domain="plonepas"> + + <genericsetup:registerProfile + name="PlonePAS" + title="PlonePAS" + directory="profiles/default" + description="Extension profile for default PlonePAS setup." + provides="Products.GenericSetup.interfaces.EXTENSION" + /> + +</configure> Added: PlonePAS/trunk/profiles/default/import_steps.xml ============================================================================== --- (empty file) +++ PlonePAS/trunk/profiles/default/import_steps.xml Sun Dec 31 02:32:06 2006 @@ -0,0 +1,12 @@ +<?xml version="1.0"?> +<import-steps> + <import-step id="plone-pas" version="20061230-01" + handler="Products.PlonePAS.setuphandlers.setupPlonePAS" + title="PlonePAS setup"> + <dependency step="componentregistry"/> + <dependency step="controlpanel"/> + <dependency step="memberdata-properties"/> + <dependency step="rolemap"/> + PlonePAS installation step. + </import-step> +</import-steps> Added: PlonePAS/trunk/profiles/default/plone-pas.txt ============================================================================== --- (empty file) +++ PlonePAS/trunk/profiles/default/plone-pas.txt Sun Dec 31 02:32:06 2006 @@ -0,0 +1 @@ +The plone-pas step is run if this file is present in the profile Added: PlonePAS/trunk/setuphandlers.py ============================================================================== --- (empty file) +++ PlonePAS/trunk/setuphandlers.py Sun Dec 31 02:32:06 2006 @@ -0,0 +1,82 @@ +""" +PlonePAS setup handlers. +""" + +from StringIO import StringIO + +from Products.CMFCore.utils import getToolByName +from Products.CMFPlone.migrations.v2_5.two51_two52 import \ + setLoginFormInCookieAuth + +from Products.PlonePAS.Extensions.Install import challenge_chooser_setup +from Products.PlonePAS.Extensions.Install import configurePlonePAS +from Products.PlonePAS.Extensions.Install import migrate_root_uf +from Products.PlonePAS.Extensions.Install import setupTools + + +def addRolesToPlugIn(p): + """ + XXX This is horrible.. need to switch PlonePAS to a GenericSetup + based install so this doesn't need to happen. + + Have to manually register the roles from the 'rolemap' step + with the roles plug-in. + """ + uf = getToolByName(p, 'acl_users') + rmanager = uf.portal_role_manager + roles = ('Reviewer', 'Member') + existing = rmanager.listRoleIds() + for role in roles: + if role not in existing: + rmanager.addRole(role) + + +def setupGroups(p): + """ + Create Plone's default set of groups. + """ + gtool = getToolByName(p, 'portal_groups') + existing = gtool.listGroupIds() + if 'Administrators' not in existing: + gtool.addGroup('Administrators', roles=['Manager']) + if 'Reviewers' not in existing: + gtool.addGroup('Reviewers', roles=['Reviewer']) + + +def installPAS(portal): + out = StringIO() + + # Simply delete any existing user folder at first + if 'acl_users' in portal.objectIds(): + portal.manage_delObjects(['acl_users']) + + # Add user folder + portal.manage_addProduct['PluggableAuthService'].addPluggableAuthService() + + # Configure Challenge Chooser plugin if available + challenge_chooser_setup(portal, out) + + # A bunch of general configuration settings + configurePlonePAS(portal, out) + + # Migrate tools + setupTools(portal, out) + + # TODO: This is highly questionable behaviour. Replacing the UF at the root. + migrate_root_uf(portal, out) + + +def setupPlonePAS(context): + """ + Setup PlonePAS step. + """ + # Only run step if a flag file is present (e.g. not an extension profile) + if context.readDataFile('plone-pas.txt') is None: + return + out = [] + site = context.getSite() + installPAS(site) + addRolesToPlugIn(site) + setupGroups(site) + + setLoginFormInCookieAuth(site, out) |