<?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 encoding="cdata"><![CDATA[

from Products.Formulator.Errors import ValidationError, FormValidationError\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n
\n
N_ = lambda msg, **kw: Message(\'erp5_ui\', msg, **kw)\n
request = context.REQUEST\n
portal = context.getPortalObject()\n
getObject = portal.portal_catalog.getObject\n
getActionsFor = portal.portal_workflow.getActionsFor\n
\n
form = getattr(context, dialog_id)\n
kw = {}\n
for f in form.get_fields():\n
  k = f.getId()\n
  if k.startswith(\'my_\'):\n
    k = k[3:]\n
  elif k.startswith(\'your_\'):\n
    k = k[5:]\n
  v = getattr(request, k, None)\n
  if v is not None:\n
    kw[k] = v\n
\n
# If there are checked uids, pass the workflow for all checked uids.\n
selection_uid_list = context.portal_selections.getSelectionCheckedUidsFor(\n
                                                       selection_name)\n
if not selection_uid_list:\n
  # else call the selection to apply to all object with\n
  # current search parameters\n
  selection_list = context.portal_selections.callSelectionFor(\n
                                     selection_name, context=context)\n
else :\n
  selection_list = [getObject(uid) for uid in selection_uid_list]\n
\n
len_selection_list = len(selection_list)\n
if len_selection_list == context.countFolder():\n
  value_error = N_("Refusing to process the entire module")\n
else:\n
  # generate a random tag\n
  tag = \'folder_workflow_action_%s\' % portal.portal_ids.generateNewLongId()\n
\n
  processed_object_count = 0    \n
  for o in selection_list:\n
    o = o.getObject()\n
    if workflow_action in [ai[\'id\'] for ai in getActionsFor(o)\n
                                          if ai.has_key(\'id\')]:\n
      o.activate(tag=tag).Base_workflowStatusModify(batch=1, **kw)\n
      processed_object_count += 1\n
  # activate something on the folder, this way the folder will be marked to\n
  # have activity and the user will be informed when this batch processing is\n
  # finished\n
  context.activate(after_tag=tag).getTitle()\n
\n
  value_error = N_("Workflow modification in progress for "\n
        "${processed_object_count} out of ${selected_object_count}",\n
         mapping=dict(processed_object_count=processed_object_count,\n
                      selected_object_count=len_selection_list))\n
                              \n
redirect_url = \'%s/%s?portal_status_message=%s&form_id=%s\' % (\n
                                 context.absolute_url(), form_id\n
                                , value_error, form_id,\n
                                )\n
\n
return request.RESPONSE.redirect( redirect_url )\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>_owner</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>form_id, dialog_id, selection_name, workflow_action</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>4</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>form_id</string>
                            <string>dialog_id</string>
                            <string>selection_name</string>
                            <string>workflow_action</string>
                            <string>Products.Formulator.Errors</string>
                            <string>ValidationError</string>
                            <string>FormValidationError</string>
                            <string>Products.DCWorkflow.DCWorkflow</string>
                            <string>ValidationFailed</string>
                            <string>Products.ERP5Type.Message</string>
                            <string>Message</string>
                            <string>N_</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>request</string>
                            <string>portal</string>
                            <string>getObject</string>
                            <string>getActionsFor</string>
                            <string>getattr</string>
                            <string>form</string>
                            <string>kw</string>
                            <string>_getiter_</string>
                            <string>f</string>
                            <string>k</string>
                            <string>_getitem_</string>
                            <string>None</string>
                            <string>v</string>
                            <string>_write_</string>
                            <string>selection_uid_list</string>
                            <string>selection_list</string>
                            <string>append</string>
                            <string>$append0</string>
                            <string>uid</string>
                            <string>len</string>
                            <string>len_selection_list</string>
                            <string>value_error</string>
                            <string>tag</string>
                            <string>processed_object_count</string>
                            <string>o</string>
                            <string>ai</string>
                            <string>_apply_</string>
                            <string>dict</string>
                            <string>redirect_url</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Folder_modifyWorkflowStatus</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
