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,13 +217,22 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -217,13 +217,22 @@ 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
if getattr(klass,method_id,None) is not None:
method = getattr(klass, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
setattr(klass, method_id, WorkflowMethod(method, method_id))
else:
method = getattr(prop_holder, method_id) method = getattr(prop_holder, method_id)
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
...@@ -234,13 +243,19 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0): ...@@ -234,13 +243,19 @@ def initializePortalTypeDynamicProperties(self, klass, ptype, recursive=0):
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
if getattr(klass,method_id,None) is not None:
method = getattr(klass, method_id)
if callable(method):
if not isinstance(method, WorkflowMethod):
method = WorkflowMethod(method, method_id)
setattr(klass, method_id, method)
else:
method = getattr(prop_holder, method_id) method = getattr(prop_holder, method_id)
if callable(method): if callable(method):
if not isinstance(method, WorkflowMethod): if not isinstance(method, WorkflowMethod):
......
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