<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </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>listbox = []\n
result_dict = {}\n
translate_state_dict = {}\n
state_dict={}\n
portal_type_dict={}\n
workflow_dict={}\n
portal_workflow = context.portal_workflow\n
content_type_list = context.allowedContentTypes()\n
content_type_list.sort()\n
\n
translateString = context.Base_translateString\n
\n
workflow_tool = context.portal_workflow\n
for portal_type in content_type_list:\n
  portal_type_id = portal_type.getId()\n
  workflow_list = workflow_tool.getWorkflowsFor(portal_type_id)\n
  # Retrieve the workflows by portal_type\n
  for workflow in workflow_list:\n
    # not \'edit_workflow\' because state variable is not in catalog\n
    if getattr(workflow, \'states\', None) is not None and \\\n
      workflow.getId() != \'edit_workflow\':\n
      #retrieve state_var to search in the catalog the states use by the\n
      #workflow\n
      state_var = workflow.state_var\n
      result_list = context.Base_zCountByWorkflowState(portal_type=portal_type_id,\n
                                                       state_name=state_var)\n
      if not ((len(result_list) == 1) and (result_list[0][0] is None)):\n
        for result in result_list:\n
          portal_type_dict = result_dict.get(portal_type_id,{})\n
          workflow_dict = portal_type_dict.get(workflow.title,{})\n
          workflow_dict.update({result[0]:result[1]})\n
          portal_type_dict.update({workflow.title:workflow_dict})\n
          result_dict.update({portal_type_id:portal_type_dict})\n
          # store the title states for the translation\n
          if not translate_state_dict.has_key(result[0]):\n
            state_title = getattr(workflow.states, result[0]).title_or_id()\n
            translate_state_dict[result[0]] = state_title\n
\n
#Display the result\n
state_list_dict = {}\n
portal_type_list = result_dict.keys()\n
portal_type_list.sort()\n
for portal_type in portal_type_list:\n
  workflow_list = result_dict[portal_type].keys()\n
  for workflow_title in workflow_list:\n
    listbox.append({\'translated_portal_type\': \'%s - %s\' %\\\n
      (translateString(portal_type), translateString(workflow_title)),\n
                    \'state\'      : \'\',\n
                    \'count\'      : \'\'})\n
    state_list = result_dict[portal_type][workflow_title].keys()\n
    state_list.sort()\n
    for state in state_list:\n
      result_count = result_dict[portal_type][workflow_title][state]\n
      count = state_list_dict.get(state, 0) + result_count\n
      # account the number of items by state\n
      state_list_dict.update({state:count})\n
      listbox.append({\'translated_portal_type\': \'\',\n
                      \'state\'      : translateString(translate_state_dict[state]),\n
                      \'count\'      : result_count})\n
\n
#Display the total by state\n
listbox.append({\'translated_portal_type\': translateString(\'All\'),\n
                \'state\'      : \'\',\n
                \'count\'      : \'\'})\n
state_list = state_list_dict.keys()\n
state_list.sort()\n
for state in state_list:\n
  listbox.append({\'translated_portal_type\': \'\',\n
                  \'state\'      : translateString(translate_state_dict[state]),\n
                  \'count\'      : state_list_dict[state]})\n
\n
context.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n
return context.Folder_viewWorkflowReport()\n
</string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>_proxy_roles</string> </key>
            <value>
              <tuple>
                <string>Manager</string>
              </tuple>
            </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>0</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>listbox</string>
                            <string>result_dict</string>
                            <string>translate_state_dict</string>
                            <string>state_dict</string>
                            <string>portal_type_dict</string>
                            <string>workflow_dict</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>portal_workflow</string>
                            <string>content_type_list</string>
                            <string>translateString</string>
                            <string>workflow_tool</string>
                            <string>_getiter_</string>
                            <string>portal_type</string>
                            <string>portal_type_id</string>
                            <string>workflow_list</string>
                            <string>workflow</string>
                            <string>getattr</string>
                            <string>None</string>
                            <string>state_var</string>
                            <string>result_list</string>
                            <string>len</string>
                            <string>_getitem_</string>
                            <string>result</string>
                            <string>state_title</string>
                            <string>_write_</string>
                            <string>state_list_dict</string>
                            <string>portal_type_list</string>
                            <string>workflow_title</string>
                            <string>state_list</string>
                            <string>state</string>
                            <string>result_count</string>
                            <string>count</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_generateWorkflowReport</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
