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
Yusei Tahara
erp5
Commits
476d6715
Commit
476d6715
authored
Jan 02, 2015
by
wenjie.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
==== DEPLOY erp5workflow_list ====
parent
5a980f25
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
36 deletions
+44
-36
product/ERP5/tests/testBase.py
product/ERP5/tests/testBase.py
+1
-1
product/ERP5Type/Base.py
product/ERP5Type/Base.py
+19
-16
product/ERP5Type/ERP5Type.py
product/ERP5Type/ERP5Type.py
+11
-8
product/ERP5Type/dynamic/lazy_class.py
product/ERP5Type/dynamic/lazy_class.py
+13
-11
No files found.
product/ERP5/tests/testBase.py
View file @
476d6715
...
@@ -1288,7 +1288,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
...
@@ -1288,7 +1288,7 @@ class TestBase(ERP5TypeTestCase, ZopeTestCase.Functional):
"""
"""
module
=
self
.
portal
.
person_module
module
=
self
.
portal
.
person_module
person
=
module
.
newContent
(
portal_type
=
'Person'
)
person
=
module
.
newContent
(
portal_type
=
'Person'
)
self
.
assertEqual
(
person
.
getValidationState
(),
'draft'
)
self
.
assertEqual
(
person
.
getValidationState
Id
(),
'draft'
)
self
.
assertFalse
(
self
.
portal
.
portal_workflow
.
isTransitionPossible
(
person
,
self
.
assertFalse
(
self
.
portal
.
portal_workflow
.
isTransitionPossible
(
person
,
'invalidate'
))
'invalidate'
))
# test low-level implementation
# test low-level implementation
...
...
product/ERP5Type/Base.py
View file @
476d6715
...
@@ -120,9 +120,6 @@ def resetRegisteredWorkflowMethod(portal_type=None):
...
@@ -120,9 +120,6 @@ def resetRegisteredWorkflowMethod(portal_type=None):
method
.
reset
(
portal_type
=
portal_type
)
method
.
reset
(
portal_type
=
portal_type
)
def
resetRegisteredERP5WorkflowMethod
(
portal_type
=
None
):
def
resetRegisteredERP5WorkflowMethod
(
portal_type
=
None
):
"""
TODO: unwrap workflow methos which were standard methods initially
"""
for
method
in
erp5workflow_method_registry
:
for
method
in
erp5workflow_method_registry
:
method
.
reset
(
portal_type
=
portal_type
)
method
.
reset
(
portal_type
=
portal_type
)
...
@@ -146,11 +143,7 @@ class ERP5WorkflowMethod(Method):
...
@@ -146,11 +143,7 @@ class ERP5WorkflowMethod(Method):
self
.
_transition_id
=
method
.
__name__
self
.
_transition_id
=
method
.
__name__
else
:
else
:
self
.
_transition_id
=
id
self
.
_transition_id
=
id
# Only publishable methods can be published as interactions
# A pure private method (ex. _doNothing) can not be published
# This is intentional to prevent methods such as submit, share to
# be called from a URL. If someone can show that this way
# is wrong (ex. for remote operation of a site), let us know.
if
not
method
.
__name__
.
startswith
(
'_'
):
if
not
method
.
__name__
.
startswith
(
'_'
):
self
.
__name__
=
method
.
__name__
self
.
__name__
=
method
.
__name__
for
func_id
in
[
'func_code'
,
'func_defaults'
,
'func_dict'
,
'func_doc'
,
'func_globals'
,
'func_name'
]:
for
func_id
in
[
'func_code'
,
'func_defaults'
,
'func_dict'
,
'func_doc'
,
'func_globals'
,
'func_name'
]:
...
@@ -206,20 +199,20 @@ class ERP5WorkflowMethod(Method):
...
@@ -206,20 +199,20 @@ class ERP5WorkflowMethod(Method):
if
not
candidate_transition_item_list
:
if
not
candidate_transition_item_list
:
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
return
apply
(
self
.
__dict__
[
'_m'
],
(
instance
,)
+
args
,
kw
)
if
instance
.
getTypeInfo
().
getTypeWorkflowList
():
if
instance
.
getTypeInfo
().
getType
ERP5
WorkflowList
():
wf5_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
wf5_module
=
instance
.
getPortalObject
().
getDefaultModule
(
portal_type
=
"Workflow"
)
### Build the list of method which is call and will be invoked.
### 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
(
'Executing %s in %s'
%
(
transition_id
,
wf_id
),
WARNING
,
"lol"
)
if
wf5_module
.
_getOb
(
wf_id
).
isERP5WorkflowMethodSupported
(
instance
,
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
transition_id
)):
if
wf5_module
.
_getOb
(
wf_id
).
isERP5WorkflowMethodSupported
(
instance
,
wf5_module
.
_getOb
(
wf_id
).
_getOb
(
transition_id
)):
#if wf5_module._getOb(wf_id)._getOb(transition_id) in instance.getCategoryStateValue().getDestinationValueList():
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
#else: ### don't do anything if no supported
else
:
#raise UnsupportedWorkflowMethod(instance, wf_id, transition_id
)
raise
NotImplementedError
(
"The Transition is not supported by current state."
)
if
valid_list
:
if
valid_list
:
valid_transition_item_list
.
append
((
wf_id
,
valid_list
))
valid_transition_item_list
.
append
((
wf_id
,
valid_list
))
...
@@ -252,6 +245,17 @@ class ERP5WorkflowMethod(Method):
...
@@ -252,6 +245,17 @@ class ERP5WorkflowMethod(Method):
"""
"""
erp5workflow_method_registry
.
append
(
self
)
erp5workflow_method_registry
.
append
(
self
)
def
reset
(
self
,
portal_type
=
None
):
"""
Reset the list of registered interactions or transitions
"""
if
portal_type
:
self
.
_invoke_once
[
portal_type
]
=
{}
self
.
_invoke_always
[
portal_type
]
=
{}
else
:
self
.
_invoke_once
=
{}
self
.
_invoke_always
=
{}
class
WorkflowMethod
(
Method
):
class
WorkflowMethod
(
Method
):
def
__init__
(
self
,
method
,
id
=
None
,
reindex
=
1
):
def
__init__
(
self
,
method
,
id
=
None
,
reindex
=
1
):
...
@@ -664,7 +668,7 @@ def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
...
@@ -664,7 +668,7 @@ def intializePortalTypeERP5WorkflowMethod(ptype_klass, portal_ERP5Workflow):
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__
)
for
ERP5Workflow
in
pt
.
workflow_list
:
for
ERP5Workflow
in
pt
.
erp5
workflow_list
:
for
tr
in
wf5_module
.
_getOb
(
ERP5Workflow
).
objectValues
(
portal_type
=
"Transition"
):
for
tr
in
wf5_module
.
_getOb
(
ERP5Workflow
).
objectValues
(
portal_type
=
"Transition"
):
tr_id
=
tr
.
id
tr_id
=
tr
.
id
method_id
=
convertToMixedCase
(
tr_id
)
method_id
=
convertToMixedCase
(
tr_id
)
...
@@ -1512,8 +1516,8 @@ class Base( CopyContainer,
...
@@ -1512,8 +1516,8 @@ class Base( CopyContainer,
ERP5PropertyManager
.
_setPropValue
(
self
,
key
,
value
)
ERP5PropertyManager
.
_setPropValue
(
self
,
key
,
value
)
#except ConflictError:
#except ConflictError:
# raise
# raise
# This should not be there, because this ignore all checks made by
# This should not be there, because this ignore
s
all checks made by
# the PropertyManager. If there
is
problems, please complain to
# the PropertyManager. If there
are
problems, please complain to
# seb@nexedi.com
# seb@nexedi.com
#except:
#except:
# # This should be removed if we want strict property checking
# # This should be removed if we want strict property checking
...
@@ -1612,7 +1616,6 @@ class Base( CopyContainer,
...
@@ -1612,7 +1616,6 @@ class Base( CopyContainer,
for
method
in
permissions
[
1
]:
for
method
in
permissions
[
1
]:
if
method
.
startswith
(
'set'
):
if
method
.
startswith
(
'set'
):
restricted_method_set
.
add
(
method
)
restricted_method_set
.
add
(
method
)
getProperty
=
self
.
getProperty
getProperty
=
self
.
getProperty
hasProperty
=
self
.
hasProperty
hasProperty
=
self
.
hasProperty
_setProperty
=
self
.
_setProperty
_setProperty
=
self
.
_setProperty
...
...
product/ERP5Type/ERP5Type.py
View file @
476d6715
...
@@ -241,7 +241,7 @@ class ERP5TypeInformation(XMLObject,
...
@@ -241,7 +241,7 @@ class ERP5TypeInformation(XMLObject,
acquire_local_roles
=
False
acquire_local_roles
=
False
property_sheet_list
=
()
property_sheet_list
=
()
base_category_list
=
()
base_category_list
=
()
workflow_list
=
()
erp5
workflow_list
=
()
init_script
=
''
init_script
=
''
product
=
'ERP5Type'
product
=
'ERP5Type'
hidden_content_type_list
=
()
hidden_content_type_list
=
()
...
@@ -418,8 +418,10 @@ class ERP5TypeInformation(XMLObject,
...
@@ -418,8 +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
)
for
ERP5Workflow
in
self
.
getTypeWorkflowList
():
### zwj: checked 31 Dec 2104
for
ERP5Workflow
in
self
.
getTypeERP5WorkflowList
():
workflow_module
=
portal
.
getDefaultModule
(
portal_type
=
"Workflow"
)
workflow_module
=
portal
.
getDefaultModule
(
portal_type
=
"Workflow"
)
if
workflow_module
is
not
None
:
ERP5Workflow
=
workflow_module
.
_getOb
(
ERP5Workflow
)
ERP5Workflow
=
workflow_module
.
_getOb
(
ERP5Workflow
)
ERP5Workflow
.
initializeDocument
(
ob
)
ERP5Workflow
.
initializeDocument
(
ob
)
...
@@ -453,11 +455,12 @@ class ERP5TypeInformation(XMLObject,
...
@@ -453,11 +455,12 @@ class ERP5TypeInformation(XMLObject,
"""Getter for 'type_base_category' property"""
"""Getter for 'type_base_category' property"""
return
list
(
self
.
base_category_list
)
return
list
(
self
.
base_category_list
)
### erp5workflow get erp5workflow_list
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'getTypeWorkflowList'
)
'getType
ERP5
WorkflowList'
)
def
getTypeWorkflowList
(
self
):
def
getType
ERP5
WorkflowList
(
self
):
"""Getter for 'type_workflow' property"""
"""Getter for 'type_workflow' property"""
return
list
(
self
.
workflow_list
)
return
list
(
self
.
erp5
workflow_list
)
def
getTypePropertySheetValueList
(
self
):
def
getTypePropertySheetValueList
(
self
):
type_property_sheet_list
=
self
.
getTypePropertySheetList
()
type_property_sheet_list
=
self
.
getTypePropertySheetList
()
...
@@ -584,7 +587,7 @@ class ERP5TypeInformation(XMLObject,
...
@@ -584,7 +587,7 @@ class ERP5TypeInformation(XMLObject,
self
.
getTypeInitScriptId
()]
self
.
getTypeInitScriptId
()]
search_source_list
+=
self
.
getTypePropertySheetList
()
search_source_list
+=
self
.
getTypePropertySheetList
()
search_source_list
+=
self
.
getTypeBaseCategoryList
()
search_source_list
+=
self
.
getTypeBaseCategoryList
()
search_source_list
+=
self
.
getTypeWorkflowList
()
search_source_list
+=
self
.
getType
ERP5
WorkflowList
()
return
' '
.
join
(
filter
(
None
,
search_source_list
))
return
' '
.
join
(
filter
(
None
,
search_source_list
))
security
.
declarePrivate
(
'getDefaultViewFor'
)
security
.
declarePrivate
(
'getDefaultViewFor'
)
...
...
product/ERP5Type/dynamic/lazy_class.py
View file @
476d6715
...
@@ -286,10 +286,11 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
...
@@ -286,10 +286,11 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
else
:
else
:
initializePortalTypeDynamicWorkflowMethods
(
cls
,
portal_workflow
)
initializePortalTypeDynamicWorkflowMethods
(
cls
,
portal_workflow
)
portal_type
=
site
.
getDefaultModule
(
portal_type
=
"portal_types"
)
portal_types
=
site
.
getDefaultModule
(
portal_type
=
"portal_types"
)
pt
=
portal_type
.
_getOb
(
cls
.
__name__
,
None
)
object_ptype
=
portal_types
.
_getOb
(
cls
.
__name__
,
None
)
if
pt
is
not
None
:
if
object_ptype
is
not
None
:
workflow_list
=
getattr
(
pt
,
'workflow_list'
,
None
)
workflow_list
=
getattr
(
object_ptype
,
'erp5workflow_list'
,
None
)
try
:
if
workflow_list
is
not
None
:
if
workflow_list
is
not
None
:
portal_ERP5Workflow
=
site
.
getDefaultModule
(
portal_type
=
"Workflow"
)
portal_ERP5Workflow
=
site
.
getDefaultModule
(
portal_type
=
"Workflow"
)
if
portal_ERP5Workflow
is
None
:
if
portal_ERP5Workflow
is
None
:
...
@@ -298,7 +299,8 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
...
@@ -298,7 +299,8 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
%
cls
.
__name__
)
%
cls
.
__name__
)
else
:
else
:
intializePortalTypeERP5WorkflowMethod
(
cls
,
portal_ERP5Workflow
)
intializePortalTypeERP5WorkflowMethod
(
cls
,
portal_ERP5Workflow
)
except
:
pass
# 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