Commit 90590e64 authored by Jean-Paul Smets's avatar Jean-Paul Smets

Better workflow scripts. Additional state for deletion.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14402 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent c7984289
......@@ -68,16 +68,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>o = state_change[\'object\']\n
ref = o.getReference()\n
if ref is None: # this shouldn\'t happen\n
raise Exception(\'how on earth can reference be None?\')\n
lng = o.getLanguage()\n
if lng is None: # ibidem\n
raise Exception(\'how on earth can language be None?\')\n
res = context.portal_catalog(reference=ref, language=lng, simulation_state=\'published\')\n
for ob in [r.getObject() for r in res]: # again, this should never happen, but still\n
o.portal_workflow.doActionFor(ob, \'archive_action\')\n
<value> <string>context.archiveVersion(state_change, validation_state=\'published\')\n
</string> </value>
</item>
<item>
......@@ -121,20 +112,8 @@ for ob in [r.getObject() for r in res]: # again, this should never happen, but s
<value>
<tuple>
<string>state_change</string>
<string>_getitem_</string>
<string>o</string>
<string>_getattr_</string>
<string>ref</string>
<string>None</string>
<string>Exception</string>
<string>lng</string>
<string>context</string>
<string>res</string>
<string>_getiter_</string>
<string>append</string>
<string>$append0</string>
<string>r</string>
<string>ob</string>
</tuple>
</value>
</item>
......
......@@ -68,16 +68,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>o = state_change[\'object\']\n
ref = o.getReference()\n
if ref is None: # this shouldn\'t happen\n
raise Exception(\'how on earth can reference be None?\')\n
lng = o.getLanguage()\n
if lng is None: # ibidem\n
raise Exception(\'how on earth can language be None?\')\n
res = context.portal_catalog(reference=ref, language=lng, simulation_state=\'released\')\n
for ob in [r.getObject() for r in res]: # again, this should never happen, but still\n
o.portal_workflow.doActionFor(ob, \'archive_action\')\n
<value> <string>context.archiveVersion(state_change, validation_state=\'released\')\n
</string> </value>
</item>
<item>
......@@ -121,20 +112,8 @@ for ob in [r.getObject() for r in res]: # again, this should never happen, but s
<value>
<tuple>
<string>state_change</string>
<string>_getitem_</string>
<string>o</string>
<string>_getattr_</string>
<string>ref</string>
<string>None</string>
<string>Exception</string>
<string>lng</string>
<string>context</string>
<string>res</string>
<string>_getiter_</string>
<string>append</string>
<string>$append0</string>
<string>r</string>
<string>ob</string>
</tuple>
</value>
</item>
......
......@@ -68,13 +68,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>"""\n
when a document is hidden\n
we have to \'uncheck\' its consistency flag\n
so that you know you have to check it again\n
"""\n
\n
#state_change.new_state.addVariable(\'consistency_state\', \'not checked\')\n
<value> <string>context.archiveVersion(state_change, validation_state=\'shared\')\n
</string> </value>
</item>
<item>
......@@ -89,12 +83,6 @@ so that you know you have to check it again\n
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change</string> </value>
......@@ -124,6 +112,8 @@ so that you know you have to check it again\n
<value>
<tuple>
<string>state_change</string>
<string>_getattr_</string>
<string>context</string>
</tuple>
</value>
</item>
......@@ -140,7 +130,7 @@ so that you know you have to check it again\n
</item>
<item>
<key> <string>id</string> </key>
<value> <string>invalidateDocument</string> </value>
<value> <string>archiveSharedVersion</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.PythonScripts.PythonScript</string>
<string>PythonScript</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Python_magic</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</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>"""\n
This script is invoked each time a new document is published.\n
The previous version is archived automatically.\n
\n
This will only apply to documents with enough coordinates\n
(ex. reference, language, version).\n
"""\n
o = state_change[\'object\']\n
reference = o.getReference()\n
if not reference:\n
# If this object has no reference, we can not do anything\n
return\n
\n
language = o.getLanguage()\n
if not language:\n
# If language is None, we have to check is this document\n
# is language independent. In this case, archival is possible\n
# But if a document exists with same reference and defined\n
# language, we can not do anything\n
for o in context.portal_catalog(reference=reference, validation_state=validation_state):\n
document = o.getObject()\n
if not document.getLanguage():\n
document.archive()\n
return\n
\n
# We can now archive all documents with same reference and language in published state\n
for o in context.portal_catalog(reference=reference, language=language, validation_state=validation_state):\n
o.getObject().archive()\n
</string> </value>
</item>
<item>
<key> <string>_code</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_filepath</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>state_change, validation_state=\'published\'</string> </value>
</item>
<item>
<key> <string>errors</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>func_code</string> </key>
<value>
<object>
<klass>
<global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>co_argcount</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>co_varnames</string> </key>
<value>
<tuple>
<string>state_change</string>
<string>validation_state</string>
<string>_getitem_</string>
<string>o</string>
<string>_getattr_</string>
<string>reference</string>
<string>language</string>
<string>_getiter_</string>
<string>context</string>
<string>document</string>
</tuple>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>func_defaults</string> </key>
<value>
<tuple>
<string>published</string>
</tuple>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>archiveVersion</string> </value>
</item>
<item>
<key> <string>warnings</string> </key>
<value>
<tuple/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -76,12 +76,12 @@ otherwise set a special variable and raise validation exception\n
"""\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
\n
ob=state_change[\'object\']\n
res = ob.checkConsistency()\n
if res:\n
msg= \'The document is not consistent:<br/>\'\n
msg += \'<br/>\'.join(\'- \' + str(r.message) for r in res)\n
raise ValidationFailed(msg)\n
object = state_change[\'object\']\n
result = object.checkConsistency()\n
if result:\n
message= \'The document is not valid:<br/>\'\n
message += \'<br/>\'.join(\'- \' + str(r.message) for r in result)\n
raise ValidationFailed(message)\n
]]></string> </value>
......@@ -130,10 +130,10 @@ if res:\n
<string>Products.DCWorkflow.DCWorkflow</string>
<string>ValidationFailed</string>
<string>_getitem_</string>
<string>ob</string>
<string>object</string>
<string>_getattr_</string>
<string>res</string>
<string>msg</string>
<string>result</string>
<string>message</string>
</tuple>
</value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<tuple>
<tuple>
<string>Products.DCWorkflow.States</string>
<string>StateDefinition</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__ac_local_roles__</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>deleted</string> </value>
</item>
<item>
<key> <string>permission_roles</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<tuple>
<tuple>
<string>Persistence</string>
<string>PersistentMapping</string>
</tuple>
<none/>
</tuple>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_container</string> </key>
<value>
<dictionary>
<item>
<key> <string>Access contents information</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>Add portal content</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>Change local roles</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>Modify portal content</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>View</string> </key>
<value>
<tuple>
<string>Manager</string>
</tuple>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -56,7 +56,7 @@
</item>
<item>
<key> <string>new_state_id</string> </key>
<value> <string>cancelled</string> </value>
<value> <string>deleted</string> </value>
</item>
<item>
<key> <string>script_name</string> </key>
......
......@@ -102,7 +102,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>python:here.getParentValue().getId() != \'portal_contributions\' and here.getDefaultModuleId(here.getPortalType()) != here.getParentValue().getId()</string> </value>
<value> <string>python:here.portal_membership.checkPermission(\'View\', here) and here.getParentValue().getId() != \'portal_contributions\' and here.getDefaultModuleId(here.getPortalType()) != here.getParentValue().getId()</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -54,7 +54,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>invalidateDocument</string> </value>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -38,7 +38,7 @@
</item>
<item>
<key> <string>after_script_name</string> </key>
<value> <string></string> </value>
<value> <string>archiveSharedVersion</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment