Commit e136b3cd authored by wenjie.zheng's avatar wenjie.zheng

======= ERP5Workflow uses validation_state from portal_categories. ======

parent 2f7e29b1
...@@ -199,32 +199,19 @@ class ERP5WorkflowMethod(Method): ...@@ -199,32 +199,19 @@ class ERP5WorkflowMethod(Method):
method5.execute(instance) method5.execute(instance)
def registerERP5TransitionAlways(self, portal_type, workflow_id, transition_id): def registerERP5TransitionAlways(self, portal_type, workflow_id, transition_id):
"""
Transitions registered as always will be invoked always
"""
transition_list = self._invoke_always.setdefault(portal_type, {}).setdefault(workflow_id, []) transition_list = self._invoke_always.setdefault(portal_type, {}).setdefault(workflow_id, [])
if transition_id not in transition_list: transition_list.append(transition_id) if transition_id not in transition_list: transition_list.append(transition_id)
self.registerERP5() self.registerERP5()
def registerERP5TransitionOncePerTransaction(self, portal_type, workflow_id, transition_id): def registerERP5TransitionOncePerTransaction(self, portal_type, workflow_id, transition_id):
"""
Transitions registered as one per transactions will be invoked
only once per transaction
"""
transition_list = self._invoke_once.setdefault(portal_type, {}).setdefault(workflow_id, []) transition_list = self._invoke_once.setdefault(portal_type, {}).setdefault(workflow_id, [])
if transition_id not in transition_list: transition_list.append(transition_id) if transition_id not in transition_list: transition_list.append(transition_id)
self.registerERP5() self.registerERP5()
def registerERP5(self): def registerERP5(self):
"""
Registers the method so that _aq_reset may later reset it
"""
erp5workflow_method_registry.append(self) erp5workflow_method_registry.append(self)
def reset(self, portal_type=None): def reset(self, portal_type=None):
"""
Reset the list of registered interactions or transitions
"""
if portal_type: if portal_type:
self._invoke_once[portal_type] = {} self._invoke_once[portal_type] = {}
self._invoke_always[portal_type] = {} self._invoke_always[portal_type] = {}
...@@ -503,11 +490,11 @@ class PropertyHolder(object): ...@@ -503,11 +490,11 @@ class PropertyHolder(object):
def registerERP5WorkflowMethod(self, id, wf_id, tr_id, once_per_transaction=0): def registerERP5WorkflowMethod(self, id, wf_id, tr_id, once_per_transaction=0):
portal_type = self.portal_type portal_type = self.portal_type
ERP5workflow_method = getattr(self, id, None) ERP5workflow_method = getattr(self, id, None)
if ERP5workflow_method is None: if ERP5workflow_method is None:
ERP5workflow_method = ERP5WorkflowMethod(Base._doNothing) ERP5workflow_method = ERP5WorkflowMethod(Base._doNothing)
setattr(self, id, ERP5workflow_method) setattr(self, id, ERP5workflow_method)
if ERP5workflow_method.__class__.__name__ == "ERP5WorkflowMethod":
if once_per_transaction: if once_per_transaction:
ERP5workflow_method.registerERP5TransitionOncePerTransaction(portal_type, ERP5workflow_method.registerERP5TransitionOncePerTransaction(portal_type,
wf_id, wf_id,
...@@ -642,7 +629,7 @@ def getClassPropertyList(klass): ...@@ -642,7 +629,7 @@ def getClassPropertyList(klass):
def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow): def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
wf5_module = aq_inner(portal_ERP5Workflow) wf5_module = aq_inner(portal_ERP5Workflow)
portal_type = portal_ERP5Workflow.getPortalObject().getDefaultModule(portal_type="portal_types") portal_type = portal_ERP5Workflow.getPortalObject().getDefaultModule(portal_type="portal_types")
pt = portal_type._getOb(ptype_klass.__name__) pt = portal_type._getOb(ptype_klass.__name__, None)
for ERP5Workflow in pt.erp5workflow_list: for ERP5Workflow in pt.erp5workflow_list:
for tr in wf5_module._getOb(ERP5Workflow).objectValues(portal_type="Transition"): for tr in wf5_module._getOb(ERP5Workflow).objectValues(portal_type="Transition"):
tr_id = tr.id tr_id = tr.id
......
...@@ -418,7 +418,6 @@ class ERP5TypeInformation(XMLObject, ...@@ -418,7 +418,6 @@ class ERP5TypeInformation(XMLObject,
for workflow in workflow_tool.getWorkflowsFor(ob): for workflow in workflow_tool.getWorkflowsFor(ob):
workflow.notifyCreated(ob) workflow.notifyCreated(ob)
### zwj: checked 31 Dec 2104
for ERP5Workflow in self.getTypeERP5WorkflowList(): for ERP5Workflow in self.getTypeERP5WorkflowList():
workflow_module = portal.getDefaultModule(portal_type="Workflow") workflow_module = portal.getDefaultModule(portal_type="Workflow")
if workflow_module is not None: if workflow_module is not None:
......
...@@ -288,21 +288,12 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder): ...@@ -288,21 +288,12 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
portal_types = site.getDefaultModule(portal_type="portal_types") portal_types = site.getDefaultModule(portal_type="portal_types")
object_ptype = portal_types._getOb(cls.__name__, None) object_ptype = portal_types._getOb(cls.__name__, None)
if hasattr(object_ptype, 'erp5workflow_list'): if object_ptype is not None:
if object_ptype.getTypeERP5WorkflowList() is not ():
ERP5Workflow = site._getOb("workflow_module", None) ERP5Workflow = site._getOb("workflow_module", None)
if ERP5Workflow is not None: if ERP5Workflow is not None:
intializePortalTypeERP5WorkflowMethod(cls, ERP5Workflow) intializePortalTypeERP5WorkflowMethod(cls, ERP5Workflow)
"""
portal_types = site.getDefaultModule(portal_type="portal_types")
object_ptype = portal_types._getOb(cls.__name__, None)
if object_ptype is not None:
workflow_list = getattr(object_ptype, 'erp5workflow_list', [])
if workflow_list is not []:
ERP5Workflow = getattr(site, "workflow_module", None)
if ERP5Workflow is not None:
intializePortalTypeERP5WorkflowMethod(cls, ERP5Workflow)
"""
# portal type group methods, isNodeType, isResourceType... # portal type group methods, isNodeType, isResourceType...
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
# XXX possible optimization: # XXX possible optimization:
......
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