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

"""Dirty script to return Software Instance state"""\n
if context.getPortalType() == "Sale Order Line":\n
  return "Under Approval"\n
\n
sale_packing_list_line = context.SoftwareInstance_getInstancePackingListLine()\n
if sale_packing_list_line is None:\n
  sale_packing_list_line = context.SoftwareInstance_getInstancePackingListLine(portal_type="Sale Order Line")\n
  if sale_packing_list_line is None:\n
    if context.getPortalObject().portal_catalog.countResults(\n
      portal_type=\'Sale Order Line\',\n
      simulation_state=\'cancelled\',\n
      default_aggregate_uid=context.getUid(),\n
      default_resource_uid=context.restrictedTraverse(context.getPortalObject().portal_preferences.getPreferredInstanceSetupResource()).getUid()\n
    )[0][0] > 0:\n
      return \'Destroyed\'\n
    # Let\'s hope the sale order is not indexed yet\n
    return \'Looking for a free partition\'\n
\n
service_url = sale_packing_list_line.getResource()\n
\n
portal_preferences = context.getPortalObject().portal_preferences\n
simulation_state = sale_packing_list_line.getSimulationState()\n
if service_url == portal_preferences.getPreferredInstanceSetupResource():\n
  if simulation_state == \'delivered\':\n
    return \'Destroyed\'\n
  elif simulation_state in (\'confirmed\', ):\n
    return \'Waiting for partition instanciation\'\n
  elif simulation_state in (\'started\', ):\n
    return \'Instanciation in progress\'\n
  elif simulation_state in (\'ordered\', ):\n
    return \'Looking for a free partition\'\n
  return \'Stopped\'\n
elif service_url == portal_preferences.getPreferredInstanceCleanupResource():\n
  if simulation_state == \'delivered\':\n
    return \'Destroyed\'\n
  return \'Destruction in progress\'\n
elif service_url == portal_preferences.getPreferredInstanceHostingResource():\n
  if simulation_state == \'confirmed\':\n
    return \'Start in progress\'\n
  elif simulation_state == \'started\':\n
    return \'Started\'\n
  elif simulation_state == \'stopped\':\n
    return \'Stop in progress\'\n
  elif simulation_state == \'delivered\':\n
    return \'Stopped\'\n
\n
return \'Unable to calculate the status...\'\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>SoftwareInstance_getStatus</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
