[CMF-checkins] CVS: CMF/DCWorkflow - DCWorkflow.py:1.30
States.py:1.13 WorkflowUIMixin.py:1.7 utils.py:1.6
Shane Hathaway
shane at zope.com
Thu Jan 15 15:52:37 EST 2004
Update of /cvs-repository/CMF/DCWorkflow
In directory cvs.zope.org:/tmp/cvs-serv706
Modified Files:
DCWorkflow.py States.py WorkflowUIMixin.py utils.py
Log Message:
The workflow can now expand abstract groups into true groups.
Here is the idea behind this: there are many specific groups, but they
are all global; there are also many general groups, but they should all
be local. DCWorkflow becomes the main component that maps between
global and local groups.
Also changed to storing group names instead of monikers, to avoid the
need to explain what a security moniker is. ;-)
=== CMF/DCWorkflow/DCWorkflow.py 1.29 => 1.30 ===
--- CMF/DCWorkflow/DCWorkflow.py:1.29 Thu Jan 15 11:15:03 2004
+++ CMF/DCWorkflow/DCWorkflow.py Thu Jan 15 15:52:06 2004
@@ -37,7 +37,7 @@
from Products.CMFCore.WorkflowTool import addWorkflowFactory
# DCWorkflow
-from utils import _dtmldir, modifyRolesForPermission, modifyRolesForGroup
+from utils import _dtmldir, modifyRolesForPermission, modifyExpandedGroups
from WorkflowUIMixin import WorkflowUIMixin
from Transitions import TRIGGER_AUTOMATIC, TRIGGER_USER_ACTION, \
TRIGGER_WORKFLOW_METHOD
@@ -74,7 +74,7 @@
scripts = None
permissions = ()
- groups = () # Security monikers of groups managed by this workflow.
+ groups = () # Names of groups managed by this workflow.
roles = None # The role names managed by this workflow.
# If roles is None, listRoles() provides a default.
@@ -424,7 +424,7 @@
roles = ()
if sdef.group_roles is not None:
roles = sdef.group_roles.get(group, ())
- if modifyRolesForGroup(ob, group, roles, managed_roles):
+ if modifyExpandedGroups(ob, group, roles, managed_roles):
changed = 1
return changed
=== CMF/DCWorkflow/States.py 1.12 => 1.13 ===
--- CMF/DCWorkflow/States.py:1.12 Thu Jan 15 11:15:03 2004
+++ CMF/DCWorkflow/States.py Thu Jan 15 15:52:06 2004
@@ -49,7 +49,7 @@
description = ''
transitions = () # The ids of possible transitions.
permission_roles = None # { permission: [role] or (role,) }
- group_roles = None # { group moniker : (role,) }
+ group_roles = None # { group name : (role,) }
var_values = None # PersistentMapping if set. Overrides transition exprs.
security = ClassSecurityInfo()
=== CMF/DCWorkflow/WorkflowUIMixin.py 1.6 => 1.7 ===
--- CMF/DCWorkflow/WorkflowUIMixin.py:1.6 Thu Jan 15 11:15:03 2004
+++ CMF/DCWorkflow/WorkflowUIMixin.py Thu Jan 15 15:52:06 2004
@@ -105,13 +105,13 @@
security.declareProtected(ManagePortal, 'getGroups')
def getGroups(self):
- """Returns the group security monikers managed by this workflow.
+ """Returns the names of groups managed by this workflow.
"""
return tuple(self.groups)
security.declareProtected(ManagePortal, 'getAvailableGroups')
def getAvailableGroups(self):
- """Returns a list of available group security monikers.
+ """Returns a list of available group names.
"""
gf = self._getGroupFolder()
if gf is None:
@@ -119,14 +119,14 @@
r = []
r.extend(gf.getDynamicGroups())
r.extend(gf.getStaticGroups())
- return [g.getSecurityMoniker() for g in r]
+ return [g.getId() for g in r]
security.declareProtected(ManagePortal, 'addGroup')
def addGroup(self, group, RESPONSE=None):
- """Adds a group by moniker.
+ """Adds a group by name.
"""
gf = self._getGroupFolder()
- g = gf.getPrincipalByMoniker(group)
+ g = gf.getGroupById(group)
if g is None:
raise ValueError(group)
self.groups = self.groups + (group,)
@@ -137,7 +137,7 @@
security.declareProtected(ManagePortal, 'delGroups')
def delGroups(self, groups, RESPONSE=None):
- """Removes groups by moniker.
+ """Removes groups by name.
"""
self.groups = tuple([g for g in self.groups if g not in groups])
if RESPONSE is not None:
=== CMF/DCWorkflow/utils.py 1.5 => 1.6 ===
--- CMF/DCWorkflow/utils.py:1.5 Thu Jan 15 11:15:03 2004
+++ CMF/DCWorkflow/utils.py Thu Jan 15 15:52:06 2004
@@ -62,19 +62,21 @@
def modifyRolesForGroup(ob, group, grant_roles, managed_roles):
"""Modifies local roles for one group.
"""
+ moniker = "(Group) %s" % group
local_roles = getattr(ob, '__ac_local_roles__', None)
if local_roles is None:
local_roles = {}
- roles = local_roles.get(group)
+ roles = local_roles.get(moniker)
if not roles:
if not grant_roles:
# No roles exist and no grants requested. Leave unchanged.
return 0
else:
# Add new roles for this group.
- local_roles[group] = tuple(grant_roles)
+ local_roles[moniker] = list(grant_roles)
ob.__ac_local_roles__ = local_roles
return 1
+ # Edit the roles.
roles = list(roles)
changed = 0
for role in managed_roles:
@@ -87,10 +89,27 @@
roles.remove(role)
changed = 1
if changed:
- if not roles and local_roles.has_key(group):
- del local_roles[group]
+ if not roles and local_roles.has_key(moniker):
+ del local_roles[moniker]
else:
- local_roles[group] = tuple(roles)
+ local_roles[moniker] = roles
ob.__ac_local_roles__ = local_roles
return changed
+def modifyExpandedGroups(ob, group, grant_roles, managed_roles):
+ """Modifies local roles for a group.
+
+ The group may expand into multiple groups as defined by an
+ aggregated group mapping.
+ """
+ groups = [group]
+ if hasattr(ob, "__group_mapping__"):
+ map = ob.getAggregatedGroupMapping()
+ expanded = map.get(group)
+ if expanded:
+ groups = expanded
+ changed = 0
+ for g in groups:
+ if modifyRolesForGroup(ob, g, grant_roles, managed_roles):
+ changed = 1
+ return changed
More information about the CMF-checkins
mailing list