Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5_fork
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Eteri
erp5_fork
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):
...
@@ -58,10 +58,11 @@ def addWorkflowFactory(factory, id, title):
assert
not
_workflow_factories
.
get
(
id
),
(
assert
not
_workflow_factories
.
get
(
id
),
(
'Workflow factory with id %r already exists.'
%
id
)
'Workflow factory with id %r already exists.'
%
id
)
factory_info
=
dict
(
factory
=
factory
,
_workflow_factories
[
id
]
=
{
id
=
id
,
'factory'
:
factory
,
title
=
title
)
'id'
:
id
,
_workflow_factories
[
id
]
=
factory_info
'title'
:
title
,
}
# register with CMF 1 if it's still there
# register with CMF 1 if it's still there
baseAddWorkflowFactory
(
factory
,
id
,
title
)
baseAddWorkflowFactory
(
factory
,
id
,
title
)
...
@@ -78,8 +79,8 @@ def _generateWorkflowConstructors(factory_info):
...
@@ -78,8 +79,8 @@ def _generateWorkflowConstructors(factory_info):
workflow_factory_id
=
factory_info
[
'id'
]
workflow_factory_id
=
factory_info
[
'id'
]
workflow_factory_title
=
factory_info
[
'title'
]
workflow_factory_title
=
factory_info
[
'title'
]
# the method names (last url segments)
# the method names (last url segments)
constructor_form_name
=
FACTORY_FORM_PREFIX
+
workflow_factory_id
constructor_form_name
=
FACTORY_FORM_PREFIX
+
workflow_factory_id
constructor_action_name
=
FACTORY_ACTION_PREFIX
+
workflow_factory_id
constructor_action_name
=
FACTORY_ACTION_PREFIX
+
workflow_factory_id
# The form
# The form
def
manage_addWorkflowForm
(
dispatcher
,
REQUEST
,
RESPONSE
):
def
manage_addWorkflowForm
(
dispatcher
,
REQUEST
,
RESPONSE
):
...
@@ -102,9 +103,10 @@ def _generateWorkflowConstructors(factory_info):
...
@@ -102,9 +103,10 @@ def _generateWorkflowConstructors(factory_info):
return
workflow
return
workflow
# The constructors
# The constructors
constructors
=
[(
constructor_form_name
,
manage_addWorkflowForm
),
return
[
(
constructor_action_name
,
manage_addWorkflow
)]
(
constructor_form_name
,
manage_addWorkflowForm
),
return
constructors
(
constructor_action_name
,
manage_addWorkflow
),
]
def
addWorkflowByType
(
container
,
workflow_factory_id
,
workflow_id
):
def
addWorkflowByType
(
container
,
workflow_factory_id
,
workflow_id
):
""" Add a workflow with name 'workflow_id' from factory identified by
""" Add a workflow with name 'workflow_id' from factory identified by
...
@@ -112,21 +114,20 @@ def addWorkflowByType(container, workflow_factory_id, workflow_id):
...
@@ -112,21 +114,20 @@ def addWorkflowByType(container, workflow_factory_id, workflow_id):
"""
"""
# This functionality could be inside the generated manage_addWorkflow above,
# This functionality could be inside the generated manage_addWorkflow above,
# but is placed here to be easily used directly from Python code.
# but is placed here to be easily used directly from Python code.
workflow_factory
=
_workflow_factories
[
workflow_factory_id
][
'factory'
]
container
.
_setObject
(
workflow_id
,
workflow
=
workflow_factory
(
workflow_id
)
_workflow_factories
[
workflow_factory_id
][
'factory'
](
workflow_id
))
container
.
_setObject
(
workflow_id
,
workflow
)
return
aq_inner
(
container
.
restrictedTraverse
(
workflow_id
))
return
aq_inner
(
container
.
restrictedTraverse
(
workflow_id
))
def
registerWorkflowFactory
(
context
,
factory_info
):
def
registerWorkflowFactory
(
context
,
factory_info
):
""" Register a workflow factory as a Zope2 style object factory that is only
""" Register a workflow factory as a Zope2 style object factory that is only
addable to portal_workflow"""
addable to portal_workflow"""
con
structors
=
_generateWorkflowConstructors
(
factory_info
)
con
text
.
registerClass
(
permission
=
Permissions
.
ManagePortal
DCWorkflowDefinition
,
# this class is only used here for its interfaces
context
.
registerClass
(
DCWorkflowDefinition
,
# this class is only used here for its interfaces
meta_type
=
factory_info
[
'title'
],
meta_type
=
factory_info
[
'title'
]
,
constructors
=
_generateWorkflowConstructors
(
factory_info
)
,
constructors
=
constructors
,
permission
=
Permissions
.
ManagePortal
,
permission
=
permission
,
visibility
=
None
,
visibility
=
None
)
)
def
registerAllWorkflowFactories
(
context
):
def
registerAllWorkflowFactories
(
context
):
"""register workflow factories during product initialization
"""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