<?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[

software_instance = state_change[\'object\']\n
tag = "%s_destroyInProgress" % software_instance.getUid()\n
portal = context.getPortalObject()\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
  raise ValueError("Software Instance is currently being destroyed.")\n
# lock software instance in transaction\n
software_instance.serialize()\n
\n
sale_order_line = software_instance.getAggregateRelatedValue(portal_type=\'Sale Order Line\')\n
\n
if sale_order_line.getSimulationState() == \'ordered\':\n
  # tries to destroy not yet even allocated one\n
  sale_order_line.getParentValue().cancel()\n
else:\n
  service_relative_url = software_instance.portal_preferences.\\\n
                              getPreferredInstanceCleanupResource()\n
  sale_packing_list = context.SoftwareInstance_createSalePackingList(state_change, service_relative_url, tag=tag)\n
  sale_packing_list.confirm(activate_kw={\'tag\':tag})\n
\n
  if software_instance.getPortalType() == "Software Instance":\n
    software_instance.SoftwareInstance_requestDestroySlaveInstanceRelated()\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>SoftwareInstance_requestDestroy</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
