Commit 03eff6f3 authored by Jérome Perrin's avatar Jérome Perrin

Also reset aq_dynamic when workflow method are added and state variable name is changed.

the comment '# XXX We should also call it whenever we change workflow defition' can be removed from ERP5Type



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@17046 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 8d05b76f
......@@ -723,7 +723,7 @@ class ERP5TypeInformation( FactoryTypeInformation,
if previous_property_sheet_list != self.property_sheet_list or \
base_category_list != self.base_category_list:
from Products.ERP5Type.Base import _aq_reset
_aq_reset() # XXX We should also call it whenever we change workflow defition
_aq_reset()
return result
def reorderActions(self, REQUEST=None):
......
......@@ -112,6 +112,22 @@ class WorkflowToolInteractor(AqDynamicInteractor):
from Products.CMFCore.WorkflowTool import WorkflowTool
self.on(WorkflowTool.manage_changeWorkflows).doAfter(self.resetAqDynamic)
class DCWorkflowInteractor(AqDynamicInteractor):
"""This interactor reset aq_dynamic method cache whenever a workflow
definition changes
"""
def install(self):
from Products.DCWorkflow.Transitions import Transitions
self.on(Transitions.addTransition).doAfter(self.resetAqDynamic)
self.on(Transitions.deleteTransitions).doAfter(self.resetAqDynamic)
from Products.DCWorkflow.Transitions import TransitionDefinition
self.on(TransitionDefinition.setProperties).doAfter(self.resetAqDynamic)
from Products.DCWorkflow.Variables import Variables
self.on(Variables.setStateVar).doAfter(self.resetAqDynamic)
## #
## # Experimental part
## #
......@@ -224,6 +240,7 @@ class InteractorOfInteractor(Interactor):
# Install some interactors:
WorkflowToolInteractor().install()
DCWorkflowInteractor().install()
# This is used in ERP5Form and install method is called in ERP5Form
# Don't install this interactor here.
......
......@@ -1692,6 +1692,35 @@ class TestPropertySheet:
props=dict(chain_Person='delivery_causality_workflow'))
self.assertTrue(hasattr(doc, 'getCausalityState'))
def test_aq_reset_on_workflow_method_change(self):
doc = self.portal.person_module.newContent(portal_type='Person')
ti = self.getTypesTool()['Person']
self.portal.portal_workflow.manage_changeWorkflows(
default_chain='',
props=dict(chain_Person='delivery_causality_workflow'))
self.assertTrue(hasattr(doc, 'diverge'))
wf = self.portal.portal_workflow.delivery_causality_workflow
wf.transitions.addTransition('dummy_workflow_method')
from Products.DCWorkflow.Transitions import TRIGGER_WORKFLOW_METHOD
wf.transitions.dummy_workflow_method.setProperties(
title='', new_state_id='', trigger_type=TRIGGER_WORKFLOW_METHOD)
self.assertTrue(hasattr(doc, 'dummyWorkflowMethod'))
wf.transitions.deleteTransitions(['dummy_workflow_method'])
self.assertFalse(hasattr(doc, 'dummyWorkflowMethod'))
def test_aq_reset_on_workflow_state_variable_change(self):
doc = self.portal.person_module.newContent(portal_type='Person')
ti = self.getTypesTool()['Person']
self.portal.portal_workflow.manage_changeWorkflows(
default_chain='',
props=dict(chain_Person='delivery_causality_workflow'))
self.assertTrue(hasattr(doc, 'getCausalityState'))
wf = self.portal.portal_workflow.delivery_causality_workflow
wf.variables.setStateVar('dummy_state')
self.assertTrue(hasattr(doc, 'getDummyState'))
# ... other cases should be added here
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment