def addRecursiveGroupsPlugin(context): """Add a recursive groups plugin to acl_users""" from Products.PluggableAuthService.plugins.RecursiveGroupsPlugin import addRecursiveGroupsPlugin, IRecursiveGroupsPlugin from Products.PluggableAuthService.interfaces.plugins import IGroupsPlugin acl = getToolByName(context, 'acl_users') plugins = acl.plugins existingPlugins = plugins.listPlugins(IGroupsPlugin) if existingPlugins: for p, id in existingPlugins: if IRecursiveGroupsPlugin.providedBy(p): plugins.deactivatePlugin(IGroupsPlugin, id) logger.warn('Found an existing Recursive Groups plugin, %s, in acl_users, deactivating.' % id) if not 'recursive_groups' in acl: addRecursiveGroupsPlugin(acl, 'recursive_groups', "Recursive Groups Plugin")