Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5-Boxiang
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
Hamza
erp5-Boxiang
Commits
4d2c21cf
Commit
4d2c21cf
authored
Oct 12, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix StateChangeInfo.setWorkflowVariable and restrict its usage for the current transition
parent
2e3f28c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
95 deletions
+5
-95
bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_ingestion_workflow/scripts/test_error_message.xml
...ocument_ingestion_workflow/scripts/test_error_message.xml
+0
-84
product/ERP5Type/patches/DCWorkflow.py
product/ERP5Type/patches/DCWorkflow.py
+1
-2
product/ERP5Type/patches/StateChangeInfoPatch.py
product/ERP5Type/patches/StateChangeInfoPatch.py
+4
-9
No files found.
bt5/erp5_dms/WorkflowTemplateItem/portal_workflow/document_ingestion_workflow/scripts/test_error_message.xml
deleted
100644 → 0
View file @
2e3f28c5
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"PythonScript"
module=
"Products.PythonScripts.PythonScript"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
Script_magic
</string>
</key>
<value>
<int>
3
</int>
</value>
</item>
<item>
<key>
<string>
_bind_names
</string>
</key>
<value>
<object>
<klass>
<global
name=
"NameAssignments"
module=
"Shared.DC.Scripts.Bindings"
/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key>
<string>
_asgns
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
name_container
</string>
</key>
<value>
<string>
container
</string>
</value>
</item>
<item>
<key>
<string>
name_context
</string>
</key>
<value>
<string>
context
</string>
</value>
</item>
<item>
<key>
<string>
name_m_self
</string>
</key>
<value>
<string>
script
</string>
</value>
</item>
<item>
<key>
<string>
name_subpath
</string>
</key>
<value>
<string>
traverse_subpath
</string>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key>
<string>
_body
</string>
</key>
<value>
<string>
transition = state_change[\'transition\'].id[len(\'user_\'):]\n
\n
def TestTitle(object):\n
"""\n
This is the test for this particular action\n
"""\n
if object.getTitle() == \'truc\':\n
return 1\n
return 0\n
\n
object = state_change[\'object\']\n
\n
if TestTitle(object):\n
method = getattr(context, transition)\n
method()\n
else:\n
kw = {\'error_message\':\'Why do you want to do this ?????\'}\n
state_change.setWorkflowVariable(object, **kw)\n
</string>
</value>
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
state_change
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test_error_message
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5Type/patches/DCWorkflow.py
View file @
4d2c21cf
...
...
@@ -400,8 +400,7 @@ def DCWorkflowDefinition_executeTransition(self, ob, tdef=None, kwargs=None):
sci
=
StateChangeInfo
(
ob
,
self
,
status
,
tdef
,
old_sdef
,
new_sdef
,
kwargs
)
# put the error message in the workflow history
sci
.
setWorkflowVariable
(
ob
,
workflow_id
=
self
.
id
,
error_message
=
before_script_error_message
)
sci
.
setWorkflowVariable
(
error_message
=
before_script_error_message
)
if
validation_exc
:
# reraise validation failed exception
raise
validation_exc
,
None
,
validation_exc_traceback
...
...
product/ERP5Type/patches/StateChangeInfoPatch.py
View file @
4d2c21cf
...
...
@@ -30,19 +30,14 @@ from Products.DCWorkflow.Expression import StateChangeInfo
from
Products.PythonScripts.Utility
import
allow_class
allow_class
(
StateChangeInfo
)
def
setWorkflowVariable
(
self
,
object
,
workflow_id
=
'edit_workflow'
,
**
kw
):
def
setWorkflowVariable
(
self
,
**
kw
):
"""
Allows to go through security checking and let a
script allows to modify a workflow variable
"""
workflow_history
=
object
.
workflow_history
for
workflow
in
workflow_history
.
keys
():
if
len
(
workflow_history
[
workflow
])
!=
0
and
workflow
==
workflow_id
:
last_status
=
workflow_history
[
workflow
][
-
1
]
for
variable
in
kw
.
keys
():
if
last_status
.
has_key
(
variable
):
last_status
[
variable
]
=
kw
[
variable
]
history
=
self
.
object
.
workflow_history
[
self
.
workflow
.
id
]
history
[
-
1
].
update
(
kw
)
history
.
_p_changed
=
1
StateChangeInfo
.
setWorkflowVariable
=
setWorkflowVariable
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