Commit 70ad0fcb authored by wenjie.zheng's avatar wenjie.zheng

lazy_class: Avoid using hasattr.

parent 9f2212cf
...@@ -269,10 +269,12 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder): ...@@ -269,10 +269,12 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
# ================== ERP5Workflow Project, Wenjie, Dec 2014 ======================= # ================== 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 ### try to get workflow_list from related types then initialize the class of types
try: pt = getattr(portal_type, cls.__name__, None)
pt = portal_type._getOb(cls.__name__) if pt is not None:
#raise NotImplemented (pt) #pt = portal_type._getOb(cls.__name__)
if hasattr(pt, 'workflow_list'): #raise NotImplemented (pt)
wf = getattr(pt, 'workflow_list', None)
if wf is not None:
### Get ERP5Workflow Module ### 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:
...@@ -282,8 +284,6 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder): ...@@ -282,8 +284,6 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else: else:
### Generate Workflow Method ### Generate Workflow Method
intializePortalTypeERP5WorkflowMethod(cls, portal_ERP5Workflow) intializePortalTypeERP5WorkflowMethod(cls, portal_ERP5Workflow)
except:
pass
# ================== WF5 ======================================================= # ================== WF5 =======================================================
# portal type group methods, isNodeType, isResourceType... # portal type group methods, isNodeType, isResourceType...
......
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