<?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 encoding="cdata"><![CDATA[

person = state_change[\'object\']\n
portal = person.getPortalObject()\n
# Get required arguments\n
kwargs = state_change.kwargs\n
\n
# Required args\n
# Raise TypeError if all parameters are not provided\n
try:\n
  computer_title = kwargs[\'computer_title\']\n
except KeyError:\n
  raise TypeError, "Person_requestComputer takes exactly 1 argument"\n
\n
tag = "%s_%s_computerInProgress" % (person.getUid(), \n
                               computer_title)\n
if (portal.portal_activities.countMessageWithTag(tag) > 0):\n
  # The software instance is already under creation but can not be fetched from catalog\n
  # As it is not possible to fetch informations, it is better to raise an error\n
  raise NotImplementedError(tag)\n
\n
computer_portal_type = "Computer"\n
computer_list = portal.portal_catalog.portal_catalog(portal_type=computer_portal_type, title=computer_title, limit=2)\n
\n
if len(computer_list) == 2:\n
  raise NotImplementedError\n
elif len(computer_list) == 1:\n
  computer = computer_list[0]\n
else:\n
  computer = None\n
\n
if computer is None:\n
  reference = "COMP-%s" % portal.portal_ids.generateNewId(\n
    id_group=\'slap_computer_reference\',\n
    id_generator=\'uid\')\n
  module = portal.getDefaultModule(portal_type=computer_portal_type)\n
  computer = module.newContent(\n
    portal_type=computer_portal_type,\n
    title=computer_title,\n
    reference=reference,\n
    capacity_scope=\'open\',\n
    activate_kw={\'tag\': tag}\n
  )\n
  computer.requestComputerRegistration()\n
  computer.approveComputerRegistration()\n
\n
\n
computer = context.restrictedTraverse(computer.getRelativeUrl())\n
\n
context.REQUEST.set("computer", computer.getRelativeUrl())\n
context.REQUEST.set("computer_url", computer.absolute_url())\n
context.REQUEST.set("computer_reference", computer.getReference())\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>Person_requestComputer</string> </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
