<?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
full_software_release_list = [si.getUrlString() for si in \n
          portal.portal_catalog(\n
            portal_type=\'Software Installation\',\n
            default_aggregate_uid=computer.getUid(),\n
            validation_state=\'validated\'\n
          ) if si.getSlapState() == \'start_requested\']\n
\n
if len(full_software_release_list) == 0:\n
  return\n
# group SR by Software Product to avoid two upgrade Decision for the same product\n
software_release_list = portal.portal_catalog(\n
                          portal_type=\'Software Release\',\n
                          url_string=full_software_release_list,\n
                          group_by=\'default_aggregate_uid\'\n
                        )\n
\n
for software_release in software_release_list:\n
  software_product_reference = software_release.getAggregateReference()\n
  sorted_list = portal.SoftwareProduct_getSortedSoftwareReleaseList(\n
    software_product_reference=software_product_reference)\n
  \n
  # Check if there is a new version of this software Product\n
  if sorted_list and \\\n
      sorted_list[0].getUrlString() not in full_software_release_list:\n
    \n
    newer_release = sorted_list[0]\n
    title = \'A new software release is available for %s\' % \\\n
                        software_product_reference\n
    # Search if exist upgrade decision for this software product (by title)\n
    is_decision_in_progress = newer_release.\\\n
            SoftwareRelease_isUpgradeDecisionInProgress(title=title)\n
    if is_decision_in_progress:\n
      continue\n
  \n
    return newer_release.SoftwareRelease_createUpgradeDecision(\n
        source_url=computer.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_checkAndCreateUpgradeDecision</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
