Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
erp5
Commits
603c8600
Commit
603c8600
authored
Dec 10, 2014
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ERP5Workflow Method Generation for live test.
parent
425949fe
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
158 additions
and
63 deletions
+158
-63
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+133
-58
product/ERP5Type/ERP5Type.py
product/ERP5Type/ERP5Type.py
+5
-4
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+20
-1
No files found.
product/ERP5Type/Base.py
View file @
603c8600
...
@@ -165,18 +165,51 @@ class WorkflowMethod(Method):
...
@@ -165,18 +165,51 @@ class WorkflowMethod(Method):
# already better than what we had. I (JPS) would prefer to use
# already better than what we had. I (JPS) would prefer to use
# critical sections in this part of the code and a
# critical sections in this part of the code and a
# thread variable which tells in which semantic context the code
# thread variable which tells in which semantic context the code
# should
n
e executed. - XXX
# should
b
e executed. - XXX
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
#=============== Workflow5 Project, Wenjie, Dec 2014 =====================
# Get Workflow5 which is an ERP5 default module.
# Available workflow5 bt should be initially installed.
# Only check Base Type obejct:
wf5_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
valid_list5
=
[]
valid_transition_item_list5
=
[]
#if instance.portal_type == "Object Type":
#raise NotImplementedError (instance.getTypeInfo())# Base Type at Object Type
if
hasattr
(
instance
.
getTypeInfo
(),
"workflow_list"
):
WorkflowList
=
instance
.
getTypeInfo
().
getTypeWorkflowList
()
#raise NotImplementedError (WorkflowList)# new_workflow
for
wf_id
in
WorkflowList
:
wf5
=
wf5_module
.
_getOb
(
wf_id
)
for
transition
in
wf5
.
objectValues
(
portal_type
=
'Transition'
):
valid_list5
.
append
(
transition
.
getId
())
#raise NotImplementedError (valid_list5) # ['transition1', 'transition2']
if
valid_list5
:
valid_transition_item_list5
.
append
((
wf_id
,
valid_list5
))
# execute method
for
wf_id
,
transition_list
in
valid_transition_item_list5
:
# ??? see original <245, 256>
for
tr
in
transition_list
:
method5
=
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method5
.
execute
(
instance
)
# also execute before & after script
#return method5._changeState(instance) # only change state
#raise NotImplementedError (instance.getId()) # new_object
#raise NotImplementedError (method5) # Transition at transition1
#raise NotImplementedError (instance.getCategoryStateTitle()) # None
#=================================== wf5 =================================
# New implementation does not use any longer wrapWorkflowMethod
# New implementation does not use any longer wrapWorkflowMethod
# but directly calls the workflow methods
# but directly calls the workflow methods
try
:
try
:
wf
=
getattr
(
instance
.
getPortalObject
(),
'portal_workflow'
)
wf
=
getattr
(
instance
.
getPortalObject
(),
'portal_workflow'
)
# portal_workflow is a list!
except
AttributeError
:
except
AttributeError
:
# XXX instance is unwrapped(no acquisition)
# XXX instance is unwrapped(no acquisition)
# XXX I must think that what is a correct behavior.(Yusei)
# XXX I must think that what is a correct behavior.(Yusei)
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
try
:
# Build a list of transitions which may need to be invoked
# Build a list of transitions which may need to be invoked
instance_path
=
instance
.
getPhysicalPath
()
instance_path
=
instance
.
getPhysicalPath
()
portal_type
=
instance
.
portal_type
portal_type
=
instance
.
portal_type
...
@@ -254,11 +287,13 @@ class WorkflowMethod(Method):
...
@@ -254,11 +287,13 @@ class WorkflowMethod(Method):
# Call whatever must be called after changing states
# Call whatever must be called after changing states
for
wf_id
,
transition_list
in
valid_transition_item_list
:
for
wf_id
,
transition_list
in
valid_transition_item_list
:
# /product/ERP5/InteractionWorkflow.py, update value, provide info
wf
[
wf_id
].
notifySuccess
(
instance
,
transition_list
,
result
,
args
=
args
,
kw
=
kw
)
wf
[
wf_id
].
notifySuccess
(
instance
,
transition_list
,
result
,
args
=
args
,
kw
=
kw
)
# Return result finally
# Return result finally
return
result
return
result
except
:
pass
# Interactions should not be disabled during normal operation. Only in very
# Interactions should not be disabled during normal operation. Only in very
# rare and specific cases like data migration. That's why it is implemented
# rare and specific cases like data migration. That's why it is implemented
# with temporary monkey-patching, instead of slowing down __call__ with yet
# with temporary monkey-patching, instead of slowing down __call__ with yet
...
@@ -492,6 +527,43 @@ def getClassPropertyList(klass):
...
@@ -492,6 +527,43 @@ def getClassPropertyList(klass):
if
p
not
in
ps_list
])
if
p
not
in
ps_list
])
return
ps_list
return
ps_list
# =================== Workflow5 Project, Wenjie, Dec 2014 ======================
### this function will be used in /product/ERP5Type/dynamic/lazy_class.py
### in generatePortalTypeAccessors()
def
intializePortalTypeERP5WorkflowMethod
(
ptype_klass
,
portal_workflow5
):
### portal_workflow5 is the entire ERP5Workflow module, need to access the
### workflow_list from instance's portal type. So only the related erp5 workflow will be used.
wf5_module
=
aq_inner
(
portal_workflow5
)
portal_type
=
portal_workflow5
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"portal_types"
)
pt
=
portal_type
.
_getOb
(
ptype_klass
.
__name__
)
#raise NotImplementedError (portal_type)
#raise NotImplementedError (wf5_module)#<Workflow Module at workflow_module>
for
workflow5
in
pt
.
workflow_list
:
for
tr
in
wf5_module
.
_getOb
(
workflow5
).
objectValues
(
portal_type
=
"Transition"
):
tr_id
=
tr
.
id
method_id
=
tr_id
wf_id
=
workflow5
ptype_klass
.
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
method_id
)
ptype_klass
.
registerWorkflowMethod
(
method_id
,
wf_id
,
tr_id
)
method
=
getattr
(
ptype_klass
,
method_id
)
# Wrap method
if
not
callable
(
method
):
LOG
(
'initializePortalTypeERP5WorkflowMethods'
,
100
,
'WARNING! Can not initialize %s on %s'
%
\
(
method_id
,
portal_type
))
continue
if
not
isinstance
(
method
,
WorkflowMethod
):
method
=
WorkflowMethod
(
method
)
setattr
(
ptype_klass
,
method_id
,
method
)
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
and also make sure simulation state is defined."""
and also make sure simulation state is defined."""
...
@@ -505,6 +577,8 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
...
@@ -505,6 +577,8 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
dc_workflow_dict
=
dict
()
dc_workflow_dict
=
dict
()
interaction_workflow_dict
=
dict
()
interaction_workflow_dict
=
dict
()
# DCworkflow
for
wf
in
portal_workflow
.
getWorkflowsFor
(
portal_type
):
for
wf
in
portal_workflow
.
getWorkflowsFor
(
portal_type
):
wf_id
=
wf
.
id
wf_id
=
wf
.
id
wf_type
=
wf
.
__class__
.
__name__
wf_type
=
wf
.
__class__
.
__name__
...
@@ -545,6 +619,7 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
...
@@ -545,6 +619,7 @@ def initializePortalTypeDynamicWorkflowMethods(ptype_klass, portal_workflow):
storage
[
wf_id
]
=
(
transition_id_set
,
trigger_dict
)
storage
[
wf_id
]
=
(
transition_id_set
,
trigger_dict
)
# Generate Workflow method:
for
wf_id
,
v
in
dc_workflow_dict
.
iteritems
():
for
wf_id
,
v
in
dc_workflow_dict
.
iteritems
():
transition_id_set
,
trigger_dict
=
v
transition_id_set
,
trigger_dict
=
v
for
tr_id
,
tdef
in
trigger_dict
.
iteritems
():
for
tr_id
,
tdef
in
trigger_dict
.
iteritems
():
...
...
product/ERP5Type/ERP5Type.py
View file @
603c8600
...
@@ -46,6 +46,7 @@ from TranslationProviderBase import TranslationProviderBase
...
@@ -46,6 +46,7 @@ from TranslationProviderBase import TranslationProviderBase
from
sys
import
exc_info
from
sys
import
exc_info
from
zLOG
import
LOG
,
ERROR
from
zLOG
import
LOG
,
ERROR
from
Products.CMFCore.exceptions
import
zExceptions_Unauthorized
from
Products.CMFCore.exceptions
import
zExceptions_Unauthorized
from
types
import
NoneType
def
getCurrentUserIdOrAnonymousToken
():
def
getCurrentUserIdOrAnonymousToken
():
"""Return connected user_id or simple token for
"""Return connected user_id or simple token for
...
@@ -421,7 +422,6 @@ class ERP5TypeInformation(XMLObject,
...
@@ -421,7 +422,6 @@ class ERP5TypeInformation(XMLObject,
for
workflow5
in
self
.
getTypeWorkflowList
():
for
workflow5
in
self
.
getTypeWorkflowList
():
workflow_module
=
portal
.
getDefaultModule
(
portal_type
=
"Workflow"
)
workflow_module
=
portal
.
getDefaultModule
(
portal_type
=
"Workflow"
)
if
workflow_module
is
not
None
:
workflow5
=
workflow_module
.
_getOb
(
workflow5
)
workflow5
=
workflow_module
.
_getOb
(
workflow5
)
workflow5
.
initializeDocument
(
ob
)
workflow5
.
initializeDocument
(
ob
)
...
@@ -531,6 +531,7 @@ class ERP5TypeInformation(XMLObject,
...
@@ -531,6 +531,7 @@ class ERP5TypeInformation(XMLObject,
"""
"""
Return all the properties of the Portal Type
Return all the properties of the Portal Type
"""
"""
### cls's class is PortalTypeMetaClass defined in ERP5Type/dynamic/lazy_class.py
cls
=
self
.
getPortalObject
().
portal_types
.
getPortalTypeClass
(
self
.
getId
())
cls
=
self
.
getPortalObject
().
portal_types
.
getPortalTypeClass
(
self
.
getId
())
return_set
=
set
()
return_set
=
set
()
for
property_dict
in
cls
.
getAccessorHolderPropertyList
(
content
=
True
):
for
property_dict
in
cls
.
getAccessorHolderPropertyList
(
content
=
True
):
...
...
product/ERP5Type/dynamic/lazy_class.py
View file @
603c8600
...
@@ -7,7 +7,7 @@ from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
...
@@ -7,7 +7,7 @@ from Products.ERP5Type.Accessor.Constant import Getter as ConstantGetter
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Globals
import
InitializeClass
from
Products.ERP5Type.Base
import
Base
as
ERP5Base
from
Products.ERP5Type.Base
import
Base
as
ERP5Base
from
.
import
aq_method_lock
from
.
import
aq_method_lock
from
Products.ERP5Type.Base
import
PropertyHolder
,
initializePortalTypeDynamicWorkflowMethods
from
Products.ERP5Type.Base
import
PropertyHolder
,
initializePortalTypeDynamicWorkflowMethods
,
intializePortalTypeERP5WorkflowMethod
from
Products.ERP5Type.Utils
import
UpperCase
from
Products.ERP5Type.Utils
import
UpperCase
from
Products.ERP5Type.Core.CategoryProperty
import
CategoryProperty
from
Products.ERP5Type.Core.CategoryProperty
import
CategoryProperty
from
ExtensionClass
import
ExtensionClass
,
pmc_init_of
from
ExtensionClass
import
ExtensionClass
,
pmc_init_of
...
@@ -266,6 +266,25 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
...
@@ -266,6 +266,25 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else
:
else
:
initializePortalTypeDynamicWorkflowMethods
(
cls
,
portal_workflow
)
initializePortalTypeDynamicWorkflowMethods
(
cls
,
portal_workflow
)
# ================== Workflow5 Project, Wenjie, Dec 2014 =======================
#raise NotImplementedError (cls.__name__) # Category Property
### the ERP5Workflow list is defined in ERP5Type, only try to get erp5workflow
### when it's an erp5workflow related type.
if
cls
.
__name__
==
"Object Type"
:
portal_workflow5
=
site
.
getDefaultModule
(
portal_type
=
"Workflow"
)
#raise NotImplementedError (portal_workflow5) #<Workflow Module at workflow_module>
#raise NotImplementedError (cls.__module__) #<class 'erp5.portal_type.Category Property'>
if
portal_workflow5
is
None
:
LOG
(
"ERP5Type.Dynamic"
,
WARNING
,
"no workflow5 methods for %s"
%
cls
.
__name__
)
else
:
intializePortalTypeERP5WorkflowMethod
(
cls
,
portal_workflow5
)
# ================== 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
# XXX possible optimization:
# XXX possible optimization:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment