<?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>"""Generic method called when submitting a form in dialog mode.\n
Responsible for validating form data and redirecting to the form action.\n
\n
"""\n
\n
from Products.Formulator.Errors import ValidationError, FormValidationError\n
from ZTUtils import make_query\n
\n
request=context.REQUEST\n
\n
#Exceptions for UI and Sort\n
if dialog_method == \'Base_configureUI\':\n
  return context.Base_configureUI(form_id=form_id,\n
                              selection_name=selection_name,\n
                              field_columns=getattr(request,\'field_columns\'),\n
                              stat_columns=getattr(request,\'stat_columns\'))\n
if dialog_method == \'Base_configureSortOn\':\n
  return context.Base_configureSortOn(form_id=form_id,\n
                              selection_name=selection_name,\n
                              field_sort_on=getattr(request,\'field_sort_on\'),\n
                              field_sort_order=getattr(request,\'field_sort_order\'))\n
\n
# we will try to use REQUEST.redirect if possible, it will not be possible if :\n
#  * we got an import_file, \n
#  * we got a listbox\n
#  * a value is None or [] or (), because this is not supported by make_query\n
cannot_redirect = 0\n
\n
MARKER = []\n
\n
try:\n
  # Validate the form\n
  kw = {}\n
  if request.has_key(\'pickle_string\'):\n
    pickle_string = request.get(\'pickle_string\')\n
    kw = context.portal_selections.getObjectFromPickle(pickle_string)\n
  #kw = context.portal_selections.getCookieInfo(request,dialog_id)\n
  if kw != {}:\n
    form = getattr(context.asContext(context=None,portal_type=context.getPortalType(),**kw),dialog_id)\n
  else:\n
    form = getattr(context,dialog_id)\n
  form.validate_all_to_request(request)\n
  kw = {\'form_id\': form_id,\n
        \'selection_name\': selection_name,\n
        \'selection_index\': None} # Missing selection_index\n
  has_listbox = 0\n
  for f in form.get_fields():\n
    k = f.id\n
    v = getattr(request, k, MARKER)\n
    if v is not MARKER:\n
      for prefix in (\'my_\', \'your_\'):\n
        if k.startswith(prefix):\n
          k = k[len(prefix):]\n
          kw[k] = v\n
          if v in (None, [], ()) or hasattr(v, \'read\') :\n
            cannot_redirect = 1\n
          break\n
      else:\n
        if k in (\'import_file\', \'listbox\'):\n
          if f.meta_type == \'ListBox\': has_listbox = 1\n
          cannot_redirect = 1\n
          kw[k] = v\n
  # Add some properties required by UI\n
  md5_object_uid_list = getattr(request,\'md5_object_uid_list\',None)\n
  kw[\'md5_object_uid_list\'] = md5_object_uid_list\n
  kw[\'cancel_url\'] = cancel_url\n
  if has_listbox:\n
    listbox_line_list = []\n
    listbox = getattr(request,\'listbox\',None)\n
    listbox_keys = listbox.keys()\n
    listbox_keys.sort()\n
    for key in listbox_keys:\n
      listbox_line = listbox[key]\n
      listbox_line[\'listbox_key\'] = key\n
      listbox_line_list.append(listbox[key])\n
    listbox_line_list = tuple(listbox_line_list)\n
    kw[\'listbox\'] = listbox_line_list\n
  if enable_pickle or (form.update_action!=\'\'):\n
    pickle_string = context.portal_selections.getPickle(**kw)\n
    request.set(\'pickle_string\', pickle_string)\n
  \n
  # if dialog_category is search, then edit the selection\n
  if dialog_category == "object_search" :\n
    context.portal_selections.setSelectionParamsFor(selection_name, kw)\n
\n
  # if we cannot redirect, then call the form directly.\n
  # XXX we always redirect in report mode to make sure portal_skin\n
  # parameter is taken into account by SkinTool.\n
  if cannot_redirect and dialog_category != "object_report" :\n
    dialog_form = getattr(context, dialog_method, None)\n
    for k, v in kw.items() :\n
      request.set(k, v)\n
    # set the URL in request, so that we can immediatly call method\n
    # that depend on it (eg. Show All). This is really related to\n
    # current ListBox implementation which edit Selection\'s last_url\n
    # with the content of REQUEST.URL\n
    request.set(\'URL\', \'%s/%s\' % (context.absolute_url(), dialog_method))\n
    return dialog_form(**kw)\n
\n
  # Otherwise, prepare URL to redirect, passing arguments in the URL\n
  # (we remove None values, as it doesn\'t work with make_query, which\n
  # pass \'None\')\n
  cleanedup_kw = {}\n
  for k, v in kw.items() :\n
    if v is not None :\n
      cleanedup_kw[k] = v\n
  redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
                            , dialog_method\n
                            , make_query(cleanedup_kw)\n
                            )\n
  return request.RESPONSE.redirect( redirect_url )\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
  return form(request)\n
\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/local_erp5/Base_callDialogMethod</string> </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string>cancel_url, dialog_method, selection_name, dialog_id, dialog_category=\'\', form_id=\'view\', enable_pickle=0, **kw</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>7</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>cancel_url</string>
                            <string>dialog_method</string>
                            <string>selection_name</string>
                            <string>dialog_id</string>
                            <string>dialog_category</string>
                            <string>form_id</string>
                            <string>enable_pickle</string>
                            <string>kw</string>
                            <string>Products.Formulator.Errors</string>
                            <string>ValidationError</string>
                            <string>FormValidationError</string>
                            <string>ZTUtils</string>
                            <string>make_query</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>request</string>
                            <string>getattr</string>
                            <string>cannot_redirect</string>
                            <string>MARKER</string>
                            <string>pickle_string</string>
                            <string>_apply_</string>
                            <string>None</string>
                            <string>form</string>
                            <string>has_listbox</string>
                            <string>_getiter_</string>
                            <string>f</string>
                            <string>k</string>
                            <string>v</string>
                            <string>prefix</string>
                            <string>_getitem_</string>
                            <string>len</string>
                            <string>_write_</string>
                            <string>hasattr</string>
                            <string>md5_object_uid_list</string>
                            <string>listbox_line_list</string>
                            <string>listbox</string>
                            <string>listbox_keys</string>
                            <string>key</string>
                            <string>listbox_line</string>
                            <string>tuple</string>
                            <string>dialog_form</string>
                            <string>cleanedup_kw</string>
                            <string>redirect_url</string>
                            <string>validation_errors</string>
                            <string>field_errors</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <tuple>
                <string></string>
                <string>view</string>
                <int>0</int>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Base_callDialogMethod</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>
