[CMF-checkins] CVS: CMF - utils.py:1.2 DCWorkflow.py:1.2
shane@digicool.com
shane@digicool.com
Mon, 11 Jun 2001 16:14:17 -0400 (EDT)
Update of /cvs-repository/CMF/DCWorkflow
In directory korak.digicool.com:/tmp/cvs-serv30374
Modified Files:
utils.py DCWorkflow.py
Log Message:
Added updateRoleMappingsFor().
--- Updated File utils.py in package CMF --
--- utils.py 2001/06/11 19:33:47 1.1
+++ utils.py 2001/06/11 20:14:16 1.2
@@ -127,4 +127,7 @@
data = value
break
p = Permission(pname, data, ob)
- p.setRoles(roles)
+ if p.getRoles() != roles:
+ p.setRoles(roles)
+ return 1
+ return 0
--- Updated File DCWorkflow.py in package CMF --
--- DCWorkflow.py 2001/06/11 19:33:47 1.1
+++ DCWorkflow.py 2001/06/11 20:14:16 1.2
@@ -450,6 +450,23 @@
'''
pass
+ security.declarePrivate('updateRoleMappingsFor')
+ def updateRoleMappingsFor(self, ob):
+ '''
+ Changes the object permissions according to the current
+ state.
+ '''
+ changed = 0
+ sdef = self._getWorkflowStateOf(ob)
+ if self.permissions:
+ for p in self.permissions:
+ roles = []
+ if sdef.permission_roles is not None:
+ roles = sdef.permission_roles.get(p, roles)
+ if modifyRolesForPermission(ob, p, roles):
+ changed = 1
+ return changed
+
def _checkTransitionGuard(self, t, ob):
guard = t.guard
if guard is None:
@@ -529,15 +546,10 @@
else:
value = vdef.default_value
status[id] = value
- # Update role to permission assignments.
- if self.permissions:
- for p in self.permissions:
- roles = []
- if sdef.permission_roles is not None:
- roles = sdef.permission_roles.get(p, roles)
- modifyRolesForPermission(ob, p, roles)
# Update state.
status[self.state_var] = state
+ # Update role to permission assignments.
+ self.updateRoleMappingsFor(ob)
tool = aq_parent(aq_inner(self))
tool.setStatusOf(self.id, ob, status)