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

from Products.CMFActivity.ActiveResult import ActiveResult\n
portal = context.getPortalObject()\n
\n
software_instance_list = context.getSpecialiseRelatedValueList(\n
  portal_type=["Slave Instance", "Software Instance"])\n
\n
if len(software_instance_list) == 1:\n
  return \n
\n
title_dict = {}\n
\n
active_process = portal.restrictedTraverse(active_process)\n
\n
for software_instance in software_instance_list:\n
  if software_instance.getSlapState() == "destroy_requested":\n
    continue\n
\n
  title = software_instance.getTitle() \n
  if title in title_dict:\n
    title_dict[title].append(software_instance.getObject())\n
  else:\n
    title_dict[title] = [software_instance.getObject()]\n
\n
\n
for title in title_dict:\n
  if len(title_dict[title]) > 1:\n
    if fixit:\n
      for software_instance in title_dict[title]:\n
        if len(software_instance.getAggregate([])) == 0:\n
          active_process.postResult(ActiveResult(\n
            summary="Fixing %s which duplication and is not allocated (%s)" \\\n
                % (software_instance.getRelativeUrl(), context.getRelativeUrl()),\n
            severity=0,\n
            detail=""))\n
          software_instance.activate().SoftwareInstance_destroyAsSelf()          \n
    else:\n
      active_process.postResult(ActiveResult(\n
         summary="%s has duplication" % context.getRelativeUrl(),\n
         severity=100,\n
         detail="%s has duplication on %s (%s)" % (context.getRelativeUrl(), title, len(title_dict[title]))))\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>fixit, active_process</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>HostingSubscription_checkDuplicatedInstance</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
