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
0
Issues
0
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
Matevz Golob
erp5
Commits
8928e85b
Commit
8928e85b
authored
Mar 27, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base.py: add compatibility features for ERP5 interaction workflow.
parent
568e7c96
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
38 deletions
+43
-38
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+43
-38
No files found.
product/ERP5Type/Base.py
View file @
8928e85b
...
@@ -181,14 +181,14 @@ class ERP5WorkflowMethod(Method):
...
@@ -181,14 +181,14 @@ class ERP5WorkflowMethod(Method):
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
if
erp5workflow_engaged
==
1
:
if
erp5workflow_engaged
==
1
:
wf
5
_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
wf_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
### zwj: Build the list of method which is call and will be invoked.
### zwj: Build the list of method which is call and will be invoked.
valid_transition_item_list
=
[]
valid_transition_item_list
=
[]
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
for
wf_id
,
transition_list
in
candidate_transition_item_list
:
valid_list
=
[]
valid_list
=
[]
for
transition_id
in
transition_list
:
for
transition_id
in
transition_list
:
LOG
(
'zwj: Type: %s Executing %s in %s'
%
(
instance
.
getPortalType
(),
transition_id
,
wf_id
),
WARNING
,
" in Base.py ERP5Workflow."
)
#
LOG('zwj: Type: %s Executing %s in %s' %(instance.getPortalType(), transition_id, wf_id), WARNING, " in Base.py ERP5Workflow.")
if
wf
5_module
.
_getOb
(
wf_id
).
isERP5WorkflowMethodSupported
(
instance
,
wf5
_module
.
_getOb
(
wf_id
).
_getOb
(
transition_id
)):
if
wf
_module
.
_getOb
(
wf_id
).
isERP5WorkflowMethodSupported
(
instance
,
wf
_module
.
_getOb
(
wf_id
).
_getOb
(
transition_id
)):
valid_list
.
append
(
transition_id
)
valid_list
.
append
(
transition_id
)
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
transactional_variable
[
once_transition_key
]
=
1
transactional_variable
[
once_transition_key
]
=
1
...
@@ -216,7 +216,7 @@ class ERP5WorkflowMethod(Method):
...
@@ -216,7 +216,7 @@ class ERP5WorkflowMethod(Method):
for
wf_id
,
transition_list
in
valid_transition_item_list
:
for
wf_id
,
transition_list
in
valid_transition_item_list
:
try
:
try
:
for
tr
in
transition_list
:
for
tr
in
transition_list
:
method5
=
wf
5
_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method5
=
wf_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method5
.
execute
(
instance
)
method5
.
execute
(
instance
)
except
ObjectDeleted
:
except
ObjectDeleted
:
raise
ObjectDeleted
(
result
)
raise
ObjectDeleted
(
result
)
...
@@ -344,7 +344,7 @@ class WorkflowMethod(Method):
...
@@ -344,7 +344,7 @@ class WorkflowMethod(Method):
candidate_workflow
=
wf
[
wf_id
]
candidate_workflow
=
wf
[
wf_id
]
for
transition_id
in
transition_list
:
for
transition_id
in
transition_list
:
if
candidate_workflow
.
isWorkflowMethodSupported
(
instance
,
transition_id
):
if
candidate_workflow
.
isWorkflowMethodSupported
(
instance
,
transition_id
):
LOG
(
'zwj: Type: %s Executing %s in %s'
%
(
instance
.
getPortalType
(),
transition_id
,
wf_id
),
WARNING
,
" in Base.py DCWorkflow."
)
#
LOG('zwj: Type: %s Executing %s in %s' %(instance.getPortalType(), transition_id, wf_id), WARNING, " in Base.py DCWorkflow.")
valid_list
.
append
(
transition_id
)
valid_list
.
append
(
transition_id
)
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
once_transition_key
=
once_transition_dict
.
get
((
wf_id
,
transition_id
))
if
once_transition_key
:
if
once_transition_key
:
...
@@ -654,42 +654,47 @@ def getClassPropertyList(klass):
...
@@ -654,42 +654,47 @@ def getClassPropertyList(klass):
return
ps_list
return
ps_list
def
intializePortalTypeERP5WorkflowMethod
(
ptype_klass
,
portal_ERP5Workflow
):
def
intializePortalTypeERP5WorkflowMethod
(
ptype_klass
,
portal_ERP5Workflow
):
wf
5
_module
=
aq_inner
(
portal_ERP5Workflow
)
wf_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__
,
None
)
pt
=
portal_type
.
_getOb
(
ptype_klass
.
__name__
,
None
)
workflow_dict
=
{}
interaction_workflow_dict
=
{}
for
ERP5Workflow_id
in
pt
.
erp5workflow_list
:
for
ERP5Workflow_id
in
pt
.
erp5workflow_list
:
ERP5Workflow
=
wf5_module
.
_getOb
(
ERP5Workflow_id
)
ERP5Workflow
=
wf_module
.
_getOb
(
ERP5Workflow_id
)
state_var
=
ERP5Workflow
.
getStateBaseCategory
()
wf_type
=
ERP5Workflow
.
getTypeInfo
().
getId
()
### zwj: generate erp5worflow state var accessor, override base category accessor
if
wf_type
==
'Workflow'
:
for
method_id
,
getter
in
(
state_var
=
ERP5Workflow
.
getStateBaseCategory
()
(
'get%s'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateGetter
),
### zwj: generate erp5worflow state var accessor, override base category accessor
(
'get%sTitle'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateTitleGetter
),
for
method_id
,
getter
in
(
(
'getTranslated%s'
%
UpperCase
(
state_var
),
(
'get%s'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateGetter
),
WorkflowState
.
ERP5WorkflowStateTranslatedGetter
),
(
'get%sTitle'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateTitleGetter
),
(
'getTranslated%sTitle'
%
UpperCase
(
state_var
),
(
'getTranslated%s'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateTranslatedTitleGetter
),
WorkflowState
.
ERP5WorkflowStateTranslatedGetter
),
(
'serialize%s'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateSerializeGetter
),
(
'getTranslated%sTitle'
%
UpperCase
(
state_var
),
):
WorkflowState
.
ERP5WorkflowStateTranslatedTitleGetter
),
#if not hasattr(ptype_klass, method_id):
(
'serialize%s'
%
UpperCase
(
state_var
),
WorkflowState
.
ERP5WorkflowStateSerializeGetter
),
### zwj: shouldn't override the DC accessors or the portal type using DCWorkflow will have problems
):
method
=
getter
(
method_id
,
ERP5Workflow_id
)
method
=
getter
(
method_id
,
ERP5Workflow_id
)
# Attach to portal_type
ptype_klass
.
registerAccessor
(
method
,
### zwj: if ERP5 Accessor has the same name as a defined DC accessor,
Permissions
.
AccessContentsInformation
)
### it can't tell which accessor to execute,
### it will always check DC accessor first and ignore ERP5 accessor.
transition_list
=
ERP5Workflow
.
objectValues
(
portal_type
=
"Transition"
)
### thus it should register 2 types of accessor in different folder ???
storage
=
workflow_dict
ptype_klass
.
registerAccessor
(
method
,
elif
wf_type
==
'Interaction Workflow'
:
Permissions
.
AccessContentsInformation
)
transition_list
=
ERP5Workflow
.
objectValues
(
portal_type
=
'Interaction'
)
LOG
(
"zwj: Register Accessor %s of %s"
%
(
method_id
,
ERP5Workflow_id
),
WARNING
,
" in Base.py."
)
storage
=
interaction_workflow_dict
### zwj: generate erp5workflow mehtods
else
:
for
tr
in
wf5_module
.
_getOb
(
ERP5Workflow_id
).
objectValues
(
portal_type
=
"Transition"
):
continue
tr_id
=
tr
.
id
method_id
=
convertToMixedCase
(
tr_id
)
### zwj: geranrate workflow methods
ptype_klass
.
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
for
tr
in
transition_list
:
method_id
)
if
tr
.
trigger_type
==
TRIGGER_WORKFLOW_METHOD
:
ptype_klass
.
registerERP5WorkflowMethod
(
method_id
,
ERP5Workflow_id
,
tr_id
,
0
)
tr_id
=
tr
.
getId
()
LOG
(
"zwj:ERP5Workflow method %s is generated for %s "
%
(
tr_id
,
ERP5Workflow_id
),
WARNING
,
" in Base.py"
)
method_id
=
convertToMixedCase
(
tr_id
)
ptype_klass
.
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
method_id
)
ptype_klass
.
registerERP5WorkflowMethod
(
method_id
,
ERP5Workflow_id
,
tr_id
,
0
)
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
...
@@ -3428,7 +3433,7 @@ class Base( CopyContainer,
...
@@ -3428,7 +3433,7 @@ class Base( CopyContainer,
workflow
=
self
.
portal_workflow
.
getWorkflowById
(
wf_id
)
workflow
=
self
.
portal_workflow
.
getWorkflowById
(
wf_id
)
erp5workflow
=
self
.
workflow_module
.
_getOb
(
wf_id
,
None
)
erp5workflow
=
self
.
workflow_module
.
_getOb
(
wf_id
,
None
)
LOG
(
'zwj: Loading %s'
%
erp5workflow
.
getId
(),
WARNING
,
'updating roles'
)
#
LOG('zwj: Loading %s'%erp5workflow.getId(), WARNING,'updating roles')
if
workflow
is
not
None
:
if
workflow
is
not
None
:
changed
=
workflow
.
updateRoleMappingsFor
(
self
)
changed
=
workflow
.
updateRoleMappingsFor
(
self
)
if
changed
:
if
changed
:
...
...
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