<?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>instance = state_change[\'object\']\n
# Get latest workflow transition\n
state = instance.getSlapState()\n
started = "start_requested"\n
stopped = "stop_requested"\n
\n
if (state in (started, stopped)):\n
  partition = instance.getAggregate(portal_type="Computer Partition")\n
  if (partition is not None):\n
    portal = instance.getPortalObject()\n
    delivery = instance.getCausalityValue(portal_type=["Sale Packing List"])\n
    update_service_relative_url = portal.portal_preferences.getPreferredInstanceUpdateResource()\n
\n
    software_release_document = instance.Base_getSoftwareReleaseDocument(instance.getRootSoftwareReleaseUrl())\n
    if software_release_document is None:\n
      raise NotImplemnetedError(\'Software Release %r not ready yet\' % instance.getRootSoftwareReleaseUrl())\n
    if delivery is None:\n
      new_delivery = context.Instance_createSalePackingList(state_change, portal.restrictedTraverse(update_service_relative_url), software_release_document)\n
    else:\n
      new_delivery = delivery.Base_createCloneDocument(batch_mode=1)\n
    new_delivery.edit(start_date=DateTime(), stop_date=DateTime(), causality_value=None)\n
    delivery_line = new_delivery.contentValues(portal_type="Sale Packing List Line")[0]\n
    aggregate_list = delivery_line.getAggregateList(portal_type=[\'Slave Instance\', \'Software Instance\', \'Hosting Subscription\', \'Computer Partition\'])\n
    aggregate_list.append(software_release_document.getRelativeUrl())\n
    delivery_line.edit(resource=update_service_relative_url, aggregate_list=aggregate_list)\n
    new_delivery.confirm()\n
    new_delivery.start()\n
    new_delivery.stop()\n
    new_delivery.deliver()\n
    new_delivery.startBuilding()\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>Instance_changePromiseParameter</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
