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):
method5.execute(instance)
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, [])
if transition_id not in transition_list: transition_list.append(transition_id)
self.registerERP5()
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, [])
if transition_id not in transition_list: transition_list.append(transition_id)
self.registerERP5()
def registerERP5(self):
"""
Registers the method so that _aq_reset may later reset it
"""
erp5workflow_method_registry.append(self)
def reset(self, portal_type=None):
"""
Reset the list of registered interactions or transitions
"""
if portal_type:
self._invoke_once[portal_type] = {}
self._invoke_always[portal_type] = {}
......@@ -503,17 +490,17 @@ class PropertyHolder(object):
def registerERP5WorkflowMethod(self, id, wf_id, tr_id, once_per_transaction=0):
portal_type = self.portal_type
ERP5workflow_method = getattr(self, id, None)
if ERP5workflow_method is None:
ERP5workflow_method = ERP5WorkflowMethod(Base._doNothing)
setattr(self, id, ERP5workflow_method)
if once_per_transaction:
ERP5workflow_method.registerERP5TransitionOncePerTransaction(portal_type,
if ERP5workflow_method.__class__.__name__ == "ERP5WorkflowMethod":
if once_per_transaction:
ERP5workflow_method.registerERP5TransitionOncePerTransaction(portal_type,
wf_id,
tr_id)
else:
ERP5workflow_method.registerERP5TransitionAlways(portal_type,
else:
ERP5workflow_method.registerERP5TransitionAlways(portal_type,
wf_id,
tr_id)
......@@ -642,7 +629,7 @@ def getClassPropertyList(klass):
def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
wf5_module = aq_inner(portal_ERP5Workflow)
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 tr in wf5_module._getOb(ERP5Workflow).objectValues(portal_type="Transition"):
tr_id = tr.id
......
......@@ -418,7 +418,6 @@ class ERP5TypeInformation(XMLObject,
for workflow in workflow_tool.getWorkflowsFor(ob):
workflow.notifyCreated(ob)
### zwj: checked 31 Dec 2104
for ERP5Workflow in self.getTypeERP5WorkflowList():
workflow_module = portal.getDefaultModule(portal_type="Workflow")
if workflow_module is not None:
......
......@@ -286,23 +286,14 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else:
initializePortalTypeDynamicWorkflowMethods(cls, portal_workflow)
portal_types = site.getDefaultModule(portal_type="portal_types")
object_ptype = portal_types._getOb(cls.__name__, None)
if hasattr(object_ptype, 'erp5workflow_list'):
ERP5Workflow = site._getOb("workflow_module", None)
if ERP5Workflow is not None:
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 object_ptype.getTypeERP5WorkflowList() is not ():
ERP5Workflow = site._getOb("workflow_module", None)
if ERP5Workflow is not None:
intializePortalTypeERP5WorkflowMethod(cls, ERP5Workflow)
"""
# portal type group methods, isNodeType, isResourceType...
from Products.ERP5Type.ERP5Type import ERP5TypeInformation
# 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