Commit 63b10b3f authored by Sebastien Robin's avatar Sebastien Robin

fix bug with Workflow Method and classes


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2784 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9b98a6d6
...@@ -217,35 +217,50 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -217,35 +217,50 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
tdef = wf.transitions.get(tr_id, None) tdef = wf.transitions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD: if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
method_id = convertToMixedCase(tr_id) method_id = convertToMixedCase(tr_id)
if not hasattr(prop_holder, method_id): # We have to make a difference between a method which is on
# the prop_holder or on the klass, if the method is on the
# klass, then the WorkflowMethod created also need to be on the klass
if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id):
method = WorkflowMethod(klass._doNothing, tr_id) method = WorkflowMethod(klass._doNothing, tr_id)
setattr(prop_holder, method_id, method) # Attach to portal_type setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id ) prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
#LOG('in aq_portal_type %s' % id, 0, "added transition method %s" % method_id) #LOG('in aq_portal_type %s' % id, 0, "added transition method %s" % method_id)
else: else:
# Wrap method into WorkflowMethod is needed # Wrap method into WorkflowMethod is needed
method = getattr(prop_holder, method_id) if getattr(klass,method_id,None) is not None:
if callable(method): method = getattr(klass, method_id)
if not isinstance(method, WorkflowMethod): if callable(method):
setattr(prop_holder, method_id, WorkflowMethod(method, method_id)) if not isinstance(method, WorkflowMethod):
setattr(klass, method_id, WorkflowMethod(method, method_id))
else:
method = getattr(prop_holder, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
setattr(prop_holder, method_id, WorkflowMethod(method, method_id))
elif wf.__class__.__name__ in ('InteractionWorkflowDefinition', ): elif wf.__class__.__name__ in ('InteractionWorkflowDefinition', ):
for tr_id in wf.interactions.objectIds(): for tr_id in wf.interactions.objectIds():
tdef = wf.interactions.get(tr_id, None) tdef = wf.interactions.get(tr_id, None)
if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD: if tdef.trigger_type == TRIGGER_WORKFLOW_METHOD:
for imethod_id in tdef.method_id: for imethod_id in tdef.method_id:
method_id = imethod_id method_id = imethod_id
if not hasattr(prop_holder, method_id): if not hasattr(prop_holder, method_id) and not hasattr(klass,method_id):
method = WorkflowMethod(klass._doNothing, imethod_id) method = WorkflowMethod(klass._doNothing, imethod_id)
setattr(prop_holder, method_id, method) # Attach to portal_type setattr(prop_holder, method_id, method) # Attach to portal_type
prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id ) prop_holder.security.declareProtected( Permissions.AccessContentsInformation, method_id )
#LOG('in aq_portal_type %s' % id, 0, "added interaction method %s" % method_id)
else: else:
# Wrap method into WorkflowMethod is needed # Wrap method into WorkflowMethod is needed
method = getattr(prop_holder, method_id) if getattr(klass,method_id,None) is not None:
if callable(method): method = getattr(klass, method_id)
if not isinstance(method, WorkflowMethod): if callable(method):
method = WorkflowMethod(method, method_id) if not isinstance(method, WorkflowMethod):
setattr(prop_holder, method_id, method) method = WorkflowMethod(method, method_id)
setattr(klass, method_id, method)
else:
method = getattr(prop_holder, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
setattr(prop_holder, method_id, method)
except: except:
LOG('Base', ERROR, LOG('Base', ERROR,
'Could not generate worklow transition methods for workflow %s on class %s.' % (wf_id, klass), 'Could not generate worklow transition methods for workflow %s on class %s.' % (wf_id, klass),
......
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