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

lazy_class use _getOb instead getattr, remove unnecessary commentaries.

parent 70ad0fcb
...@@ -492,7 +492,7 @@ class PropertyHolder(object): ...@@ -492,7 +492,7 @@ class PropertyHolder(object):
self.__name__ = name self.__name__ = name
self.security = ClassSecurityInfo() # We create a new security info object self.security = ClassSecurityInfo() # We create a new security info object
self.workflow_method_registry = {} self.workflow_method_registry = {}
self.erp5workflow_method_registry ={} self.erp5workflow_method_registry = {}
self._categories = [] self._categories = []
self._properties = [] self._properties = []
...@@ -659,19 +659,12 @@ def getClassPropertyList(klass): ...@@ -659,19 +659,12 @@ def getClassPropertyList(klass):
if p not in ps_list]) if p not in ps_list])
return ps_list return ps_list
# =================== ERP5Workflow Project, Wenjie, Dec 2014 ======================
### this function will be used in /product/ERP5Type/dynamic/lazy_class.py
### in generatePortalTypeAccessors()
def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow): def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
### portal_ERP5Workflow is the entire ERP5Workflow module, need to access the ### this function will be used in /product/ERP5Type/dynamic/lazy_class.py
### workflow_list from instance's portal type. So only the related erp5 workflow will be used. ### in generatePortalTypeAccessors()
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__)
#raise NotImplementedError (portal_type)
#raise NotImplementedError (wf5_module)#<Workflow Module at workflow_module>
### creat workflow method: ### creat workflow method:
for ERP5Workflow in pt.workflow_list: for ERP5Workflow in pt.workflow_list:
for tr in wf5_module._getOb(ERP5Workflow).objectValues(portal_type="Transition"): for tr in wf5_module._getOb(ERP5Workflow).objectValues(portal_type="Transition"):
...@@ -679,18 +672,6 @@ def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow): ...@@ -679,18 +672,6 @@ def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
method_id = convertToMixedCase(tr_id) method_id = convertToMixedCase(tr_id)
wf_id = ERP5Workflow wf_id = ERP5Workflow
ptype_klass.registerERP5WorkflowMethod(method_id, wf_id, tr_id, 0) ptype_klass.registerERP5WorkflowMethod(method_id, wf_id, tr_id, 0)
#ptype_klass.security.declareProtected(Permissions.AccessContentsInformation,
# method_id)
#ptype_klass.registerWorkflowMethod(method_id, wf_id, tr_id)
#method = getattr(ptype_klass, method_id)
#method = getattr(ptype_klass, method_id, _MARKER) # _MARKER = []
#if method is _MARKER:
#ptype_klass.security.declareProtected(Permissions.AccessContentsInformation,
# method_id)
# ptype_klass.registerWorkflowMethod(method_id, wf_id, tr_id, 0)
# continue
#method.registerTransitionAlways(portal_type, wf_id, tr_id)
# =================== WF5 ======================================================
def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow): def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
"""We should now make sure workflow methods are defined """We should now make sure workflow methods are defined
......
...@@ -418,14 +418,10 @@ class ERP5TypeInformation(XMLObject, ...@@ -418,14 +418,10 @@ class ERP5TypeInformation(XMLObject,
for workflow in workflow_tool.getWorkflowsFor(ob): for workflow in workflow_tool.getWorkflowsFor(ob):
workflow.notifyCreated(ob) workflow.notifyCreated(ob)
# =========== Project ERP5Workflow , WENJIE , 2014 ================================
### workflow_list need to be defined somewhere.
### exp: ERP5Workflow in Person module won't work at this situation.
for ERP5Workflow in self.getTypeWorkflowList(): for ERP5Workflow in self.getTypeWorkflowList():
workflow_module = portal.getDefaultModule(portal_type="Workflow") workflow_module = portal.getDefaultModule(portal_type="Workflow")
ERP5Workflow = workflow_module._getOb(ERP5Workflow) ERP5Workflow = workflow_module._getOb(ERP5Workflow)
ERP5Workflow.initializeDocument(ob) ERP5Workflow.initializeDocument(ob)
# =========== WF5 ==============================================================
if not temp_object: if not temp_object:
init_script = self.getTypeInitScriptId() init_script = self.getTypeInitScriptId()
......
...@@ -266,25 +266,18 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder): ...@@ -266,25 +266,18 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else: else:
initializePortalTypeDynamicWorkflowMethods(cls, portal_workflow) initializePortalTypeDynamicWorkflowMethods(cls, portal_workflow)
# ================== ERP5Workflow Project, Wenjie, Dec 2014 =======================
portal_type = site.getDefaultModule(portal_type="portal_types") portal_type = site.getDefaultModule(portal_type="portal_types")
### try to get workflow_list from related types then initialize the class of types pt = portal_type._getOb(cls.__name__, None)
pt = getattr(portal_type, cls.__name__, None)
if pt is not None: if pt is not None:
#pt = portal_type._getOb(cls.__name__) workflow_list = getattr(pt, 'workflow_list', None)
#raise NotImplemented (pt) if workflow_list is not None:
wf = getattr(pt, 'workflow_list', None)
if wf is not None:
### Get ERP5Workflow Module
portal_ERP5Workflow = site.getDefaultModule(portal_type="Workflow") portal_ERP5Workflow = site.getDefaultModule(portal_type="Workflow")
if portal_ERP5Workflow is None: if portal_ERP5Workflow is None:
LOG("ERP5Type.Dynamic", WARNING, LOG("ERP5Type.Dynamic", WARNING,
"no ERP5Workflow methods for %s" "no ERP5Workflow methods for %s"
% cls.__name__) % cls.__name__)
else: else:
### Generate Workflow Method
intializePortalTypeERP5WorkflowMethod(cls, portal_ERP5Workflow) intializePortalTypeERP5WorkflowMethod(cls, portal_ERP5Workflow)
# ================== WF5 =======================================================
# portal type group methods, isNodeType, isResourceType... # portal type group methods, isNodeType, isResourceType...
from Products.ERP5Type.ERP5Type import ERP5TypeInformation from Products.ERP5Type.ERP5Type import ERP5TypeInformation
......
############################################################################## ##############################################################################
# #
# Copyright (c) 2006 Nexedi SARL and Contributors. All Rights Reserved. # Copyright (c) 2006,2014 Nexedi SARL and Contributors. All Rights Reserved.
# Romain Courteaud <romain@nexedi.com> # Romain Courteaud <romain@nexedi.com>
# # Wenjie Zheng <wenjie.zheng@tiolive.com>
# WARNING: This program as such is intended to be used by professional # WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential # programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs # consequences resulting from its eventual inadequacies and bugs
...@@ -40,7 +40,6 @@ from Products.DCWorkflowGraph.config import DOT_EXE ...@@ -40,7 +40,6 @@ from Products.DCWorkflowGraph.config import DOT_EXE
from Products.DCWorkflowGraph.DCWorkflowGraph import bin_search, getGraph from Products.DCWorkflowGraph.DCWorkflowGraph import bin_search, getGraph
from Products.ERP5Type.Utils import UpperCase from Products.ERP5Type.Utils import UpperCase
from Acquisition import aq_base from Acquisition import aq_base
#import String
from DateTime import DateTime from DateTime import DateTime
class Workflow(XMLObject): class Workflow(XMLObject):
...@@ -143,7 +142,7 @@ class Workflow(XMLObject): ...@@ -143,7 +142,7 @@ class Workflow(XMLObject):
transition=transition, transition=transition,
transition_url=transition_url, transition_url=transition_url,
state=state) state=state)
# ========== ERP5Workflow Project, Wenjie, Dec 2014 ===============================
def isERP5WorkflowMethodSupported(self, document, transition): def isERP5WorkflowMethodSupported(self, document, transition):
sdef = self._getERP5WorkflowStateOf(document) sdef = self._getERP5WorkflowStateOf(document)
if sdef is None: if sdef is None:
...@@ -162,7 +161,7 @@ class Workflow(XMLObject): ...@@ -162,7 +161,7 @@ class Workflow(XMLObject):
sdef = self.restrictedTraverse(state_path) sdef = self.restrictedTraverse(state_path)
else: sdef = None else: sdef = None
return sdef return sdef
# =========== WF5 ==============================================================
########### ###########
## Graph ## ## Graph ##
############ ############
......
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