<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <tuple>
          <string>Products.PythonScripts.PythonScript</string>
          <string>PythonScript</string>
        </tuple>
        <none/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Python_magic</string> </key>
            <value> <string encoding="base64">O/INCg==</string> </value>
        </item>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>__ac_local_roles__</string> </key>
            <value>
              <none/>
            </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[

from Products.Formulator.Errors import ValidationError, FormValidationError\n
portal = context.getPortalObject()\n
N_ = portal.Base_translateString\n
request=context.REQUEST\n
\n
#### Workaround for bug #21\n
if not request.AUTHENTICATED_USER.has_permission(\'Modify portal content\', context) :\n
  redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&%s\' % ( context.absolute_url()\n
     , form_id, selection_index, selection_name, \'portal_status_message=You+don\\\'t+have+the+permissions+to+edit+the+object.\')\n
  request[ \'RESPONSE\' ].redirect( redirect_url )\n
  return\n
\n
MARKER = []\n
\n
try:\n
  # Define form basic fields\n
  if dialog_id==\'\' or dialog_id is None:\n
    form = getattr(context,form_id)\n
  else:\n
    form = getattr(context,dialog_id)\n
  # Validate\n
  form.validate_all_to_request(request)\n
  # Basic attributes\n
  kw = {}\n
  encapsulated_editor_list = []\n
  # Parse attributes\n
  for f in form.get_fields():\n
    k = f.id\n
    v = getattr(request, k, MARKER)\n
    if hasattr(v, \'edit\'):\n
      # This is an encapsulated editor\n
      # call it\n
      encapsulated_editor_list.append(v)\n
#       v.edit(context)\n
      pass\n
    elif v is not MARKER:\n
      if k[0:3] == \'my_\':\n
        # We only take into account\n
        # the object attributes\n
        k = k[3:]\n
        # XXXX The formulate is badly designed, no value should be None.\n
        if v == \'\':\n
          v = None\n
        kw[k] = v\n
\n
  # Update matrix attributes\n
  # It is possible to display multiples matrixbox on the same form,\n
  # if they are named matrixbox, matrixbox1, matrixbox2, ...\n
#   matrixbox = request.get(\'matrixbox\')\n
  matrixbox_field_id = \'matrixbox\'\n
  matrixbox_number = 0\n
  matrixbox = request.get(matrixbox_field_id)\n
#   if matrixbox is not None:\n
  while matrixbox is not None:\n
    matrixbox_field = form.get_field(matrixbox_field_id)\n
    cell_base_id = matrixbox_field.get_value(\'cell_base_id\')\n
    portal_type = matrixbox_field.get_value(\'cell_portal_type\')\n
    getter_method = matrixbox_field.get_value(\'getter_method\')\n
    if getter_method not in (None,\'\'):\n
      matrix_context = getattr(context,getter_method)()\n
    else:\n
      matrix_context = context\n
      \n
    if matrix_context is not None:\n
      kd = {}\n
      kd[\'portal_type\'] = portal_type\n
      kd[\'base_id\'] = cell_base_id\n
      gv = {}\n
      if matrixbox_field.has_value(\'global_attributes\'):\n
        hidden_attributes = map(lambda x:x[0], matrixbox_field.get_value(\'global_attributes\'))\n
        for k in hidden_attributes:\n
          gv[k] = getattr(request, k,None)\n
\n
\n
      if matrixbox_field.get_value(\'update_cell_range\'):\n
        # Update cell range each time it is modified\n
        lines = matrixbox_field.get_value(\'lines\')\n
        columns = matrixbox_field.get_value(\'columns\')\n
        tabs = matrixbox_field.get_value(\'tabs\')\n
\n
        column_ids = map(lambda x: x[0], columns)\n
        line_ids = map(lambda x: x[0], lines)\n
        tab_ids = map(lambda x: x[0], tabs)\n
\n
        # There are 3 cases\n
        # Case 1: we do 1 dimensional matrices\n
        # Case 2: we do 2 dimensional matrices\n
        # Case 3: we do 2 dimensinal matrices + tabs\n
\n
        cell_range = matrix_context.getCellRange(base_id = cell_base_id)\n
\n
        if (len(column_ids) == 0) or (column_ids[0] == None):\n
          matrixbox_cell_range = [line_ids]\n
          if cell_range != matrixbox_cell_range:\n
            matrix_context.setCellRange(line_ids, base_id=cell_base_id)\n
\n
        elif (len(tab_ids) == 0) or (tab_ids[0] == None):\n
          matrixbox_cell_range = [line_ids, column_ids]\n
          if cell_range != matrixbox_cell_range:\n
            matrix_context.setCellRange(line_ids, column_ids, base_id=cell_base_id)\n
\n
        else:\n
          matrixbox_cell_range = [line_ids, column_ids, tab_ids]\n
          if cell_range != matrixbox_cell_range:\n
            matrix_context.setCellRange(line_ids, column_ids, tab_ids, base_id=cell_base_id)\n
\n
\n
      for k,v in matrixbox.items():\n
          # Only update cells which still exist\n
          if matrix_context.hasInRange(*k, **kd):\n
            c = matrix_context.newCell(*k, **kd)\n
            if c is not None:\n
              c.edit(**gv)  # First update globals which include the def. of property_list\n
              if v.has_key(\'variated_property\'):\n
                # For Variated Properties\n
                value = v[\'variated_property\']\n
                del v[\'variated_property\']\n
                if gv.has_key(\'mapped_value_property_list\'):\n
                  # Change the property which is defined by the\n
                  # first element of mapped_value_property_list\n
                  # XXX May require some changes with Sets\n
                  key = gv[\'mapped_value_property_list\'][0]\n
                  v[key] = value\n
              c.edit(**v) # and update the cell specific values\n
            else:\n
              return "Could not create cell %s" % str(k)\n
          else:\n
            return "Cell %s does not exist" % str(k)\n
\n
    matrixbox_number += 1\n
    matrixbox_field_id = \'matrixbox%s\' % matrixbox_number\n
    matrixbox = request.get(matrixbox_field_id)\n
\n
  # Update listbox attributes\n
  list_block_error=[]\n
  planning_box = request.get(\'planning_box\')\n
  listbox = request.get(\'listbox\')\n
  request_selection_name = request.get(\'selection_name\')\n
\n
  # XXX XXX XXX don t remove. It prevent to delete listbox object property after a selection for a RelationField...\n
  # must really improve !!!\n
  #if listbox is not None and request_selection_name==selection_name:\n
  if listbox is not None:\n
    listbox_field = form.get_field(\'listbox\')\n
    gv = {}\n
    if listbox_field.has_value(\'global_attributes\'):\n
      hidden_attributes = map(lambda x:x[0], listbox_field.get_value(\'global_attributes\'))\n
      for k in hidden_attributes:\n
        gv[k] = getattr(request, k,None)\n
    for url, v in listbox.items():\n
      o = context.restrictedTraverse(url)\n
      v.update(gv)\n
      o.edit(**v)\n
      # This below was disabled by yo. Do not use flushActivity. It is forbidden.\n
      # If you want to reactivate this, ask yo before doing.\n
      #o.flushActivity(method_id="immediateReindexObject",\n
      #                   invoke = 1) # This is required if we wish to provide immediate display\n
      #o.flushActivity(method_id="recursiveImmediateReindexObject",\n
      #                         invoke = 1) # Requires if we want to display indexed subobject data... but long\n
      # However it seems it reindexed many many times... XXX\n
      # Maybe we should build a list of objects we need\n
\n
  if planning_box is not None:\n
    planning_box_field = form.get_field(\'planning_box\')\n
    gv = {}\n
\n
    for url, v in planning_box.items():\n
      o = context.restrictedTraverse(url)\n
      v.update(gv)\n
      o.edit(**v)\n
      # This below was disabled by yo. Do not use flushActivity. It is forbidden.\n
      # If you want to reactivate this, ask yo before doing.\n
      #o.flushActivity(method_id="immediateReindexObject",\n
      #                   invoke = 1) # This is required if we wish to provide immediate display\n
      #o.flushActivity(method_id="recursiveImmediateReindexObject",\n
      #                         invoke = 1) # Requires if we want to display indexed subobject data... but long\n
      # However it seems it reindexed many many times... XXX\n
    \n
  # Maybe we should build a list of objects we need\n
  # Update basic attributes\n
  context.edit(REQUEST=request,**kw)\n
  for encapsulated_editor in encapsulated_editor_list:\n
    encapsulated_editor.edit(context)\n
\n
except FormValidationError, validation_errors:\n
  # Pack errors into the request\n
  field_errors = form.ErrorFields(validation_errors)\n
  request.set(\'field_errors\', field_errors)\n
  # Make sure editors are pushed back as values into the REQUEST object\n
  for f in form.get_fields():\n
    field_id = f.id\n
    if request.has_key(field_id):\n
      value = request.get(field_id)\n
      if callable(value):\n
        value(request)\n
  return form(request)\n
\n
else:\n
  message = N_("Data+Updated.")\n
  if not(ignore_layout) and context.getApplicableLayout() :\n
    redirect_url = \'%s/%s?editable_mode=1\' % (context.REQUEST.URL1, form_id)\n
  elif not selection_index:\n
    redirect_url = \'%s/%s?portal_status_message=%s\' % ( context.absolute_url()\n
                              , form_id\n
                              , message\n
                              )\n
  else:\n
    redirect_url = \'%s/%s?selection_index=%s&selection_name=%s&portal_status_message=%s\' % ( \n
                                context.absolute_url()\n
                              , form_id\n
                              , selection_index\n
                              , selection_name\n
                              , message\n
                              )\n
\n
\n
\n
request[ \'RESPONSE\' ].redirect( redirect_url )\n
# vim: syntax=python\n


]]></string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_dav_writelocks</string> </key>
            <value>
              <persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
            </value>
        </item>
        <item>
            <key> <string>_filepath</string> </key>
            <value> <string>Script (Python):/nexedi/portal_skins/erp5_core/Base_edit</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>form_id, selection_index=0, selection_name=\'\', dialog_id=\'\', ignore_layout=None</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>5</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>form_id</string>
                            <string>selection_index</string>
                            <string>selection_name</string>
                            <string>dialog_id</string>
                            <string>ignore_layout</string>
                            <string>Products.Formulator.Errors</string>
                            <string>ValidationError</string>
                            <string>FormValidationError</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>portal</string>
                            <string>N_</string>
                            <string>request</string>
                            <string>redirect_url</string>
                            <string>_getitem_</string>
                            <string>MARKER</string>
                            <string>None</string>
                            <string>getattr</string>
                            <string>form</string>
                            <string>kw</string>
                            <string>encapsulated_editor_list</string>
                            <string>_getiter_</string>
                            <string>f</string>
                            <string>k</string>
                            <string>v</string>
                            <string>hasattr</string>
                            <string>_write_</string>
                            <string>matrixbox_field_id</string>
                            <string>matrixbox_number</string>
                            <string>matrixbox</string>
                            <string>matrixbox_field</string>
                            <string>cell_base_id</string>
                            <string>portal_type</string>
                            <string>getter_method</string>
                            <string>matrix_context</string>
                            <string>kd</string>
                            <string>gv</string>
                            <string>map</string>
                            <string>hidden_attributes</string>
                            <string>lines</string>
                            <string>columns</string>
                            <string>tabs</string>
                            <string>column_ids</string>
                            <string>line_ids</string>
                            <string>tab_ids</string>
                            <string>cell_range</string>
                            <string>len</string>
                            <string>matrixbox_cell_range</string>
                            <string>_apply_</string>
                            <string>c</string>
                            <string>value</string>
                            <string>key</string>
                            <string>str</string>
                            <string>list_block_error</string>
                            <string>planning_box</string>
                            <string>listbox</string>
                            <string>request_selection_name</string>
                            <string>listbox_field</string>
                            <string>url</string>
                            <string>o</string>
                            <string>planning_box_field</string>
                            <string>encapsulated_editor</string>
                            <string>validation_errors</string>
                            <string>field_errors</string>
                            <string>field_id</string>
                            <string>callable</string>
                            <string>message</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <int>0</int>
                <string></string>
                <string></string>
                <none/>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Base_edit</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
  <record id="2" aka="AAAAAAAAAAI=">
    <pickle>
      <tuple>
        <tuple>
          <string>Persistence</string>
          <string>PersistentMapping</string>
        </tuple>
        <none/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>_container</string> </key>
            <value>
              <dictionary/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
