<?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>from DateTime import DateTime\n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from zExceptions import Unauthorized\n
\n
def markHistory(document, comment):\n
  document.portal_workflow.doActionFor(document, action=\'edit_action\', comment=comment)\n
\n
state = context.getSimulationState()\n
portal = context.getPortalObject()\n
order = context.getParentValue()\n
if state in [\'planned\', \'ordered\']:\n
  instance = context.getAggregateValue(portal_type=[\'Software Instance\', \'Slave Instance\'])\n
  instance_software_release_url = instance.getRootSoftwareReleaseUrl()\n
  line_software_release_document = context.getAggregateValue(portal_type=\'Software Release\')\n
  line_software_release_url = \'\'\n
  if line_software_release_document is not None:\n
    line_software_release_url = line_software_release_document.getUrlString()\n
\n
  software_release_document = context.Base_getSoftwareReleaseDocument(instance_software_release_url)\n
\n
  if line_software_release_url == \'\' or \\\n
    line_software_release_url != instance_software_release_url:\n
    if software_release_document is not None:\n
      # update\n
      aggregate_value_list = [q for q in context.getAggregateValueList() if q.getPortalType() != \'Software Release\']\n
      aggregate_value_list.append(software_release_document)\n
      context.setAggregateValueList(aggregate_value_list)\n
      if context.getSimulationState() == \'planned\':\n
        context.getParentValue().order(comment=\'Associated Software Release with %r\' % software_release_document.getUrlString())\n
      else:\n
        markHistory(context.getParentValue(), comment=\'Updated Software Release with %r\' % software_release_document.getUrlString())\n
      return True\n
    else:\n
      return False\n
  else:\n
    # nothing to do, all asserted\n
    return True\n
\n
return False\n
</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>SaleOrderLine_tryToAssociateSoftwareRelease</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
