<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </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[

# Updates relation of an ERP5 document\n
from Products.ERP5Type.Message import Message\n
from Products.Formulator.Errors import ValidationError\n
\n
# XXX: Harcoded value, which must be taken from RelationField.py\n
# XXX why not import it then ???\n
SUB_FIELD_ID = \'relation\'\n
\n
if listbox_uid is not None:\n
  selection_tool = context.getPortalObject().portal_selections\n
  selected_uids = selection_tool.updateSelectionCheckedUidList(\n
              selection_name, listbox_uid, uids)\n
  uids = selection_tool.getSelectionCheckedUidsFor(selection_name)\n
\n
old_request = dict(saved_form_data)\n
\n
field = getattr(context, form_id).get_field(field_id)\n
field_key = field.generate_field_key()\n
if old_request.has_key(\'sub_index\'):\n
  if len(uids) > 0:\n
    # XXX Hardcoded\n
    sub_field_key = field.generate_subfield_key("%s_%s" % (SUB_FIELD_ID, old_request[\'sub_index\']), key=field_key)\n
    old_request[sub_field_key] = str(uids[0])\n
else:\n
  # XXX Not very dynamic...\n
  sub_field_key = field.generate_subfield_key(SUB_FIELD_ID, key=field_key)\n
  old_request[sub_field_key] = uids\n
\n
\n
request = container.REQUEST\n
request_form = request.form\n
for k in request_form.keys():\n
  del request_form[k]\n
\n
request.form.update(old_request)\n
return context.Base_edit(form_id,\n
                         selection_index=old_request.get(\'selection_index\', 0),\n
                         selection_name=old_request.get(\'selection_name\', \'\'))\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>form_id, field_id, selection_index, selection_name, uids, listbox_uid, saved_form_data, batch_mode=0, object_uid=0</string> </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>9</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>form_id</string>
                            <string>field_id</string>
                            <string>selection_index</string>
                            <string>selection_name</string>
                            <string>uids</string>
                            <string>listbox_uid</string>
                            <string>saved_form_data</string>
                            <string>batch_mode</string>
                            <string>object_uid</string>
                            <string>Products.ERP5Type.Message</string>
                            <string>Message</string>
                            <string>Products.Formulator.Errors</string>
                            <string>ValidationError</string>
                            <string>SUB_FIELD_ID</string>
                            <string>None</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>selection_tool</string>
                            <string>selected_uids</string>
                            <string>dict</string>
                            <string>old_request</string>
                            <string>getattr</string>
                            <string>field</string>
                            <string>field_key</string>
                            <string>len</string>
                            <string>_getitem_</string>
                            <string>sub_field_key</string>
                            <string>str</string>
                            <string>_write_</string>
                            <string>container</string>
                            <string>request</string>
                            <string>request_form</string>
                            <string>_getiter_</string>
                            <string>k</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <int>0</int>
                <int>0</int>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Base_editRelation</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
