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
Laurent S
erp5
Commits
06fa1e65
Commit
06fa1e65
authored
Apr 28, 2015
by
wenjie.zheng
Committed by
Sebastien Robin
Jul 16, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Base.py: modify workflow getter since workflow_module has been merged with portal_workflow.
parent
c866c993
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
27 deletions
+17
-27
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+17
-27
No files found.
product/ERP5Type/Base.py
View file @
06fa1e65
...
...
@@ -125,7 +125,6 @@ def resetRegisteredERP5WorkflowMethod(portal_type=None):
class
ERP5WorkflowMethod
(
Method
):
### to get the name of the class
### do object.__class__.__name__
def
__init__
(
self
,
method
,
id
=
None
,
reindex
=
1
):
self
.
_m
=
method
if
id
is
None
:
...
...
@@ -147,7 +146,7 @@ class ERP5WorkflowMethod(Method):
def
__call__
(
self
,
instance
,
*
args
,
**
kw
):
if
getattr
(
self
,
'__name__'
,
None
)
in
(
'getPhysicalPath'
,
'getId'
,
'getRef'
,
):
if
getattr
(
self
,
'__name__'
,
None
)
in
(
'getPhysicalPath'
,
'getId'
,):
return
self
.
_m
(
instance
,
*
args
,
**
kw
)
# Build a list of transitions which may need to be invoked
...
...
@@ -180,7 +179,7 @@ class ERP5WorkflowMethod(Method):
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
try
:
wf_module
=
instance
.
getPortalObject
().
getDefaultModule
(
"Workflow"
)
### portal_workflow
wf_module
=
instance
.
getPortalObject
().
portal_workflow
### portal_workflow
except
AttributeError
:
return
self
.
_m
(
instance
,
*
arge
,
**
kw
)
...
...
@@ -205,7 +204,7 @@ class ERP5WorkflowMethod(Method):
for
wf_id
,
transition_list
in
valid_transition_item_list
:
try
:
for
tr
in
transition_list
:
method
=
wf_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
### _getObjectByRef
method
=
wf_module
.
_getOb
(
wf_id
).
_getOb
(
tr
)
method
.
execute
(
instance
)
except
ObjectDeleted
:
raise
ObjectDeleted
(
result
)
...
...
@@ -213,7 +212,6 @@ class ERP5WorkflowMethod(Method):
raise
ObjectMoved
(
ex
.
getNewObject
(),
result
)
def
registerERP5TransitionAlways
(
self
,
portal_type
,
workflow_id
,
transition_id
):
LOG
(
'register trigger %s in portal type %s'
%
(
transition_id
,
portal_type
),
WARNING
,
'in Base.py'
)
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
()
...
...
@@ -658,11 +656,7 @@ def initializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
ERP5Workflow = wf_module._getOb(ERP5Workflow_id)
"""
for
ERP5Workflow
in
portal_workflow
.
getWorkflowValueListFor
(
portal_type_value
):
if
not
ERP5Workflow
.
isTempObject
():
ERP5Workflow_id
=
ERP5Workflow
.
getId
()
### getRef, merge this condiction
else
:
# copatibility for temporary object
ERP5Workflow_id
=
ERP5Workflow
.
getTitle
()
### getRef
ERP5Workflow_id
=
ERP5Workflow
.
getId
()
### getRef, merge this condiction
workflow_type
=
ERP5Workflow
.
__class__
.
__name__
#zwj: for DC compatibility
LOG
(
" zwj. Found Workflow type = %s"
%
workflow_type
,
WARNING
,
" in Base.py."
)
if
workflow_type
==
'Workflow'
or
workflow_type
==
'DCWorkflowDefinition'
:
...
...
@@ -685,32 +679,31 @@ def initializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
Permissions
.
AccessContentsInformation
)
if
workflow_type
==
'Workflow'
:
LOG
(
'1.1 Generation %s type %s method
%s'
%
(
workflow_type
,
ERP5Workflow_id
,
method
_id
),
WARNING
,
' in Base.py'
)
LOG
(
'1.1 Generation %s type %s method
'
%
(
workflow_type
,
ERP5Workflow
_id
),
WARNING
,
' in Base.py'
)
transition_id_list
=
[]
#ERP5Workflow.objectIds(portal_type='Transition')
transition_list
=
ERP5Workflow
.
objectValues
(
portal_type
=
'Transition'
)
for
tr
in
transition_list
:
transition_id_list
.
append
(
tr
.
getId
(
))
### getRef, this id list is actually a reference list
transition_id_list
.
append
(
'_'
.
join
(
tr
.
getId
().
split
(
'_'
)[:
-
1
]
))
### getRef, this id list is actually a reference list
LOG
(
'1.1.1 transition_id_list = %s'
%
transition_id_list
,
WARNING
,
' in Base.py'
)
elif
workflow_type
==
'DCWorkflowDefinition'
:
LOG
(
'1.2 Generation %s type %s method
%s'
%
(
workflow_type
,
ERP5Workflow_id
,
method
_id
),
WARNING
,
' in Base.py'
)
LOG
(
'1.2 Generation %s type %s method
'
%
(
workflow_type
,
ERP5Workflow
_id
),
WARNING
,
' in Base.py'
)
transition_id_list
=
ERP5Workflow
.
transitions
transition_list
=
[]
for
transition_id
in
transition_id_list
:
transition
=
ERP5Workflow
.
transitions
.
get
(
transition_id
)
transition_list
.
append
(
transition
)
storage
=
workflow_dict
elif
workflow_type
==
'Interaction Workflow'
or
workflow_type
==
'InteractionWorkflowDefinition'
:
LOG
(
" 2. Found Interaction Workflow :%s"
%
ERP5Workflow_id
,
WARNING
,
" in Base.py."
)
if
workflow_type
==
'Interaction Workflow'
:
LOG
(
'2.1 Generation %s type %s method
%s'
%
(
workflow_type
,
ERP5Workflow_id
,
method
_id
),
WARNING
,
' in Base.py'
)
LOG
(
'2.1 Generation %s type %s method
'
%
(
workflow_type
,
ERP5Workflow
_id
),
WARNING
,
' in Base.py'
)
transition_id_list
=
[]
#ERP5Workflow.objectIds(portal_type='Interaction') ### not sure if it works
transition_list
=
ERP5Workflow
.
objectValues
(
portal_type
=
'Interaction'
)
for
tr
in
transition_list
:
transition_id_list
.
append
(
tr
.
getId
())
### getRef, this id list is actually a reference list
transition_id_list
.
append
(
'_'
.
join
(
tr
.
getId
().
split
(
'_'
)[:
-
1
]))
# remove suffinx
LOG
(
'2.1.1 transition_id_list = %s'
%
transition_id_list
,
WARNING
,
' in Base.py'
)
elif
workflow_type
==
'InteractionWorkflowDefinition'
:
LOG
(
'2.2 Generation %s type %s method
%s'
%
(
workflow_type
,
ERP5Workflow_id
,
method
_id
),
WARNING
,
' in Base.py'
)
LOG
(
'2.2 Generation %s type %s method
'
%
(
workflow_type
,
ERP5Workflow
_id
),
WARNING
,
' in Base.py'
)
transition_id_list
=
ERP5Workflow
.
interactions
for
interaction_id
in
transition_id_list
:
interaction
=
ERP5Workflow
.
interactions
.
get
(
interaction_id
)
...
...
@@ -726,15 +719,11 @@ def initializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
trigger_dict
=
{}
for
transition
in
transition_list
:
if
not
transition
.
isTempObject
():
transition_id
=
transition
.
getId
()
### getRef
else
:
transition_id
=
transition
.
getTitle
()
### getRef
transition_id
=
transition
.
getId
()
LOG
(
'4. Found transition %s'
%
transition_id
,
WARNING
,
' in Base.py'
)
if
transition
.
trigger_type
==
TRIGGER_WORKFLOW_METHOD
:
LOG
(
'4.1 Accpted transition %s'
%
transition_id
,
WARNING
,
' in Base.py'
)
trigger_dict
[
transition_id
]
=
transition
storage
[
ERP5Workflow_id
]
=
(
transition_id_set
,
trigger_dict
)
### zwj: generate Workflow methods
...
...
@@ -783,7 +772,8 @@ def initializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
transition_id_set
,
trigger_dict
=
v
for
tr_id
,
tdef
in
trigger_dict
.
iteritems
():
# check portal type filter
type_filter
=
list
(
tdef
.
portal_type_filter
)
### not use property sheet accessor for DC compatibility
LOG
(
" 776 transition id is '%s'"
%
tdef
.
getId
(),
WARNING
,
" in Base.py."
)
type_filter
=
list
(
tdef
.
portal_type_filter
)
if
(
type_filter
!=
[]
and
portal_type
not
in
type_filter
):
continue
...
...
@@ -3069,9 +3059,9 @@ class Base( CopyContainer,
def
isERP5WorkflowDeleted
(
self
):
### zwj: deal with the deleted object
for
wf_id
in
self
.
getTypeInfo
().
getTypeERP5WorkflowList
():
wf
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
).
_getOb
(
wf_id
)
### _getObjectByRef
wf
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
wf_id
)
state
=
self
.
_getDefaultAcquiredValue
(
wf
.
getStateVariable
())
if
state
is
not
None
and
state
.
getId
()
==
'deleted'
:
### getRef
if
state
is
not
None
and
state
.
getId
()
==
'deleted'
:
return
True
return
False
...
...
@@ -3115,7 +3105,7 @@ class Base( CopyContainer,
for
wf
in
self
.
portal_workflow
.
getWorkflowsFor
(
self
):
result
+=
[(
wf
.
id
,
wf
.
_getWorkflowStateOf
(
self
,
id_only
=
1
))]
for
workflow_id
in
self
.
getTypeInfo
().
getTypeERP5WorkflowList
():
workflow
=
self
.
getPortalObject
().
getDefaultModule
(
'Workflow'
)
.
_getOb
(
workflow_id
)
### _getObjectByRef
workflow
=
self
.
getPortalObject
().
portal_workflow
.
_getOb
(
workflow_id
)
### _getObjectByRef
if
workflow
.
getPortalType
()
==
'Workflow'
:
result
+=
[(
workflow_id
,
workflow
.
_getWorkflowStateOf
(
self
,
id_only
=
1
))]
return
result
...
...
@@ -3598,7 +3588,7 @@ class Base( CopyContainer,
def
updateRoleMappingsFor
(
self
,
wf_id
,
**
kw
):
workflow
=
self
.
portal_workflow
.
getWorkflowById
(
wf_id
)
erp5workflow
=
self
.
workflow_module
.
_getOb
(
wf_id
,
None
)
### _getObjectByRef
erp5workflow
=
self
.
portal_workflow
.
_getOb
(
wf_id
,
None
)
### _getObjectByRef
#LOG('zwj: Loading %s'%erp5workflow.getId(), WARNING,'updating roles')
if
workflow
is
not
None
:
changed
=
workflow
.
updateRoleMappingsFor
(
self
)
...
...
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