[CMF-checkins] CVS: CMF/DCWorkflow - DCWorkflow.py:1.11 Transitions.py:1.4
Shane Hathaway
shane@digicool.com
Wed, 24 Oct 2001 14:26:27 -0400
Update of /cvs-repository/CMF/DCWorkflow
In directory cvs.zope.org:/tmp/cvs-serv9444
Modified Files:
DCWorkflow.py Transitions.py
Log Message:
Added the ability to execute a script after the transition occurred.
=== CMF/DCWorkflow/DCWorkflow.py 1.10 => 1.11 ===
'Destination state undefined: ' + new_state)
- # Execute a script if specified.
+ # Execute the "before" script.
if tdef is not None and tdef.script_name:
script = self.scripts[tdef.script_name]
# Pass lots of info to the script in a single parameter.
@@ -603,6 +603,19 @@
# Update role to permission assignments.
self.updateRoleMappingsFor(ob)
+
+ # Execute the "after" script.
+ if tdef is not None and tdef.after_script_name:
+ script = self.scripts[tdef.after_script_name]
+ # Pass lots of info to the script in a single parameter.
+ sci = StateChangeInfo(
+ ob, self, status, tdef, old_sdef, new_sdef, kwargs)
+ try:
+ script(sci) # May throw an exception.
+ except ObjectMoved, ex:
+ ob = ex.getNewObject()
+ moved = 1
+ # Don't re-raise
# Return the new state object.
if moved:
=== CMF/DCWorkflow/Transitions.py 1.3 => 1.4 ===
actbox_category = 'workflow'
var_exprs = None # A mapping.
- script_name = None
+ script_name = None # Executed before transition
+ after_script_name = None # Executed after transition
manage_options = (
{'label': 'Properties', 'action': 'manage_properties'},
@@ -181,6 +182,7 @@
def setProperties(self, title, new_state_id,
trigger_type=TRIGGER_USER_ACTION, script_name='',
+ after_script_name='',
actbox_name='', actbox_url='',
actbox_category='workflow',
props=None, REQUEST=None):
@@ -190,6 +192,7 @@
self.new_state_id = str(new_state_id)
self.trigger_type = int(trigger_type)
self.script_name = str(script_name)
+ self.after_script_name = str(after_script_name)
g = Guard()
if g.changeFromProperties(props or REQUEST):
self.guard = g