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
Alexander Emmerich
erp5
Commits
01686717
Commit
01686717
authored
May 06, 2011
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix coding style and get rid of intermediate variables.
parent
9e0e08b4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
19 deletions
+20
-19
product/ERP5Type/Workflow.py
product/ERP5Type/Workflow.py
+20
-19
No files found.
product/ERP5Type/Workflow.py
View file @
01686717
...
...
@@ -58,10 +58,11 @@ def addWorkflowFactory(factory, id, title):
assert
not
_workflow_factories
.
get
(
id
),
(
'Workflow factory with id %r already exists.'
%
id
)
factory_info
=
dict
(
factory
=
factory
,
id
=
id
,
title
=
title
)
_workflow_factories
[
id
]
=
factory_info
_workflow_factories
[
id
]
=
{
'factory'
:
factory
,
'id'
:
id
,
'title'
:
title
,
}
# register with CMF 1 if it's still there
baseAddWorkflowFactory
(
factory
,
id
,
title
)
...
...
@@ -78,8 +79,8 @@ def _generateWorkflowConstructors(factory_info):
workflow_factory_id
=
factory_info
[
'id'
]
workflow_factory_title
=
factory_info
[
'title'
]
# the method names (last url segments)
constructor_form_name
=
FACTORY_FORM_PREFIX
+
workflow_factory_id
constructor_action_name
=
FACTORY_ACTION_PREFIX
+
workflow_factory_id
constructor_form_name
=
FACTORY_FORM_PREFIX
+
workflow_factory_id
constructor_action_name
=
FACTORY_ACTION_PREFIX
+
workflow_factory_id
# The form
def
manage_addWorkflowForm
(
dispatcher
,
REQUEST
,
RESPONSE
):
...
...
@@ -102,9 +103,10 @@ def _generateWorkflowConstructors(factory_info):
return
workflow
# The constructors
constructors
=
[(
constructor_form_name
,
manage_addWorkflowForm
),
(
constructor_action_name
,
manage_addWorkflow
)]
return
constructors
return
[
(
constructor_form_name
,
manage_addWorkflowForm
),
(
constructor_action_name
,
manage_addWorkflow
),
]
def
addWorkflowByType
(
container
,
workflow_factory_id
,
workflow_id
):
""" Add a workflow with name 'workflow_id' from factory identified by
...
...
@@ -112,21 +114,20 @@ def addWorkflowByType(container, workflow_factory_id, workflow_id):
"""
# This functionality could be inside the generated manage_addWorkflow above,
# but is placed here to be easily used directly from Python code.
workflow_factory
=
_workflow_factories
[
workflow_factory_id
][
'factory'
]
workflow
=
workflow_factory
(
workflow_id
)
container
.
_setObject
(
workflow_id
,
workflow
)
container
.
_setObject
(
workflow_id
,
_workflow_factories
[
workflow_factory_id
][
'factory'
](
workflow_id
))
return
aq_inner
(
container
.
restrictedTraverse
(
workflow_id
))
def
registerWorkflowFactory
(
context
,
factory_info
):
""" Register a workflow factory as a Zope2 style object factory that is only
addable to portal_workflow"""
con
structors
=
_generateWorkflowConstructors
(
factory_info
)
permission
=
Permissions
.
ManagePortal
context
.
registerClass
(
DCWorkflowDefinition
,
# this class is only used here for its interfaces
meta_type
=
factory_info
[
'title'
]
,
constructors
=
constructors
,
permission
=
permission
,
visibility
=
None
)
con
text
.
registerClass
(
DCWorkflowDefinition
,
# this class is only used here for its interfaces
meta_type
=
factory_info
[
'title'
],
constructors
=
_generateWorkflowConstructors
(
factory_info
)
,
permission
=
Permissions
.
ManagePortal
,
visibility
=
None
,
)
def
registerAllWorkflowFactories
(
context
):
"""register workflow factories during product initialization
...
...
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