[CMF-checkins] CVS: CMF/DCWorkflow - DCWorkflow.py:1.32
Guard.py:1.9 WorkflowUIMixin.py:1.8
Shane Hathaway
shane at zope.com
Wed Jan 28 17:05:42 EST 2004
Update of /cvs-repository/CMF/DCWorkflow
In directory cvs.zope.org:/tmp/cvs-serv8089
Modified Files:
DCWorkflow.py Guard.py WorkflowUIMixin.py
Log Message:
Managers now have the option of bypassing guard conditions.
This is useful for debugging and emergencies. Also took an opportunity to
add some missing docstrings.
=== CMF/DCWorkflow/DCWorkflow.py 1.31 => 1.32 ===
--- CMF/DCWorkflow/DCWorkflow.py:1.31 Mon Jan 26 18:06:37 2004
+++ CMF/DCWorkflow/DCWorkflow.py Wed Jan 28 17:05:11 2004
@@ -78,6 +78,8 @@
roles = None # The role names managed by this workflow.
# If roles is None, listRoles() provides a default.
+ manager_bypass = 0 # Boolean: 'Manager' role bypasses guards
+
manage_options = (
{'label': 'Properties', 'action': 'manage_properties'},
{'label': 'States', 'action': 'states/manage_main'},
=== CMF/DCWorkflow/Guard.py 1.8 => 1.9 ===
--- CMF/DCWorkflow/Guard.py:1.8 Mon Jan 26 18:06:37 2004
+++ CMF/DCWorkflow/Guard.py Wed Jan 28 17:05:11 2004
@@ -41,9 +41,14 @@
guardForm = DTMLFile('guard', _dtmldir)
def check(self, sm, wf_def, ob):
- '''
- Checks conditions in this guard.
- '''
+ """Checks conditions in this guard.
+ """
+ u_roles = None
+ if wf_def.manager_bypass:
+ # Possibly bypass.
+ u_roles = sm.getUser().getRolesInContext(ob)
+ if 'Manager' in u_roles:
+ return 1
if self.permissions:
for p in self.permissions:
if sm.checkPermission(p, ob):
@@ -52,7 +57,8 @@
return 0
if self.roles:
# Require at least one of the given roles.
- u_roles = sm.getUser().getRolesInContext(ob)
+ if u_roles is None:
+ u_roles = sm.getUser().getRolesInContext(ob)
for role in self.roles:
if role in u_roles:
break
=== CMF/DCWorkflow/WorkflowUIMixin.py 1.7 => 1.8 ===
--- CMF/DCWorkflow/WorkflowUIMixin.py:1.7 Thu Jan 15 15:52:06 2004
+++ CMF/DCWorkflow/WorkflowUIMixin.py Wed Jan 28 17:05:11 2004
@@ -43,10 +43,11 @@
manage_groups = PageTemplateFile('workflow_groups.pt', _dtmldir)
security.declareProtected(ManagePortal, 'setProperties')
- def setProperties(self, title, REQUEST=None):
- '''
- '''
+ def setProperties(self, title, manager_bypass=0, REQUEST=None):
+ """Sets basic properties.
+ """
self.title = str(title)
+ self.manager_bypass = manager_bypass and 1 or 0
if REQUEST is not None:
return self.manage_properties(
REQUEST, manage_tabs_message='Properties changed.')
@@ -55,8 +56,8 @@
security.declareProtected(ManagePortal, 'manage_permissions')
def manage_permissions(self, REQUEST, manage_tabs_message=None):
- '''
- '''
+ """Displays the form for choosing which permissions to manage.
+ """
return self._permissions_form(REQUEST,
management_view='Permissions',
manage_tabs_message=manage_tabs_message,
@@ -64,8 +65,8 @@
security.declareProtected(ManagePortal, 'addManagedPermission')
def addManagedPermission(self, p, REQUEST=None):
- '''
- '''
+ """Adds to the list of permissions to manage.
+ """
if p in self.permissions:
raise ValueError, 'Already a managed permission: ' + p
if REQUEST is not None and p not in self.getPossiblePermissions():
@@ -77,8 +78,8 @@
security.declareProtected(ManagePortal, 'delManagedPermissions')
def delManagedPermissions(self, ps, REQUEST=None):
- '''
- '''
+ """Removes from the list of permissions to manage.
+ """
if ps:
l = list(self.permissions)
for p in ps:
@@ -90,8 +91,8 @@
security.declareProtected(ManagePortal, 'getPossiblePermissions')
def getPossiblePermissions(self):
- '''
- '''
+ """Returns the list of all permissions that can be managed.
+ """
# possible_permissions is in AccessControl.Role.RoleManager.
return list(self.possible_permissions())
More information about the CMF-checkins
mailing list