<?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>software_instance = state_change[\'object\']\n
hosting_subscription_uid = state_change.kwargs[\'hosting_subscription_uid\']\n
hosting_subscription = software_instance.portal_catalog.getResultValue(uid=hosting_subscription_uid)\n
portal = software_instance.getPortalObject()\n
\n
# Get services\n
portal_preferences = portal.portal_preferences\n
service_uid_list = []\n
\n
if service_relative_url is None:\n
  for service_relative_url in \\\n
    (portal_preferences.getPreferredInstanceSetupResource(),\n
     portal_preferences.getPreferredInstanceHostingResource(),\n
     portal_preferences.getPreferredInstanceCleanupResource(),\n
     ):\n
    service = portal.restrictedTraverse(service_relative_url)\n
    service_uid_list.append(service.getUid())\n
else:\n
  service = portal.restrictedTraverse(service_relative_url)\n
  service_uid_list.append(service.getUid())\n
\n
# Packing List valid state\n
state_list = []\n
state_list.extend(portal.getPortalReservedInventoryStateList())\n
state_list.extend(portal.getPortalTransitInventoryStateList())\n
state_list.extend(portal.getPortalCurrentInventoryStateList())\n
\n
packing_list_line = portal.portal_catalog.getResultValue(\n
  portal_type=\'Sale Packing List Line\',\n
  simulation_state=state_list,\n
  aggregate_uid=hosting_subscription_uid,\n
  default_resource_uid=service_uid_list,\n
  sort_on=((\'movement.start_date\', \'DESC\'),),\n
  limit=1,\n
)\n
\n
if packing_list_line is None:\n
  raise ValueError("No sale packing list line found for %s" % \\\n
        hosting_subscription.getRelativeUrl())\n
else:\n
  return packing_list_line\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>state_change, service_relative_url=None</string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>HostingSubscription_getInstancePackingListLine</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
