<?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>computer = context\n
portal = context.getPortalObject()\n
\n
partition_list = portal.portal_catalog(portal_type=\'Computer Partition\',\n
                                        free_for_request=0,\n
                                        parent_uid=computer.getUid())\n
\n
# Get Hosting Subscription for all allocated partition\n
hosting_subscription_list = []\n
for partition in partition_list:\n
  software_instance = partition.getAggregateRelatedValue(\n
                            portal_type=\'Software Instance\')\n
  if software_instance:\n
    hs = software_instance.getSpecialiseValue(\n
                  portal_type=\'Hosting Subscription\')\n
    if hs and hs.getSlapState() in \\\n
        [\'start_requested\', \'stop_requested\'] and \\\n
        not hs in hosting_subscription_list:\n
      hosting_subscription_list.append(hs)\n
\n
if len(hosting_subscription_list) == 0:\n
  return\n
\n
for hosting_subscription in hosting_subscription_list:\n
  is_upgradable = hosting_subscription.HostingSubscription_isUpgradable()\n
  if not is_upgradable:\n
    continue\n
  \n
  newer_release_string = hosting_subscription.\\\n
                    HostingSubscription_getNewerSofwareRelease()\n
  if not newer_release_string:\n
    continue\n
  \n
  software_release = portal.portal_catalog.getResultValue(\n
                              portal_type=\'Software Release\',\n
                              url_string=newer_release_string)\n
  if not software_release:\n
    continue\n
  \n
  title = \'A new software release is available for %s\' % \\\n
                        hosting_subscription.getReference()\n
  # Search if exist upgrade decision for this Hosting Subscription (by title)\n
  is_decision_in_progress = software_release.\\\n
          SoftwareRelease_isUpgradeDecisionInProgress(title=title)\n
  if is_decision_in_progress:\n
    continue\n
\n
  return software_release.SoftwareRelease_createUpgradeDecision(\n
      source_url=hosting_subscription.getRelativeUrl(), title=title\n
    )\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Computer_hostingSubscriptionCreateUpgradeDecision</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
