Commit 27d8dd76 authored by Vincent Pelletier's avatar Vincent Pelletier

The central valirable must be kw, not request_form, to pass arguments away -...

The central valirable must be kw, not request_form, to pass arguments away - but keep resuqet_form updated when kw is, for compatibility.
Fix selection_name being accessed directly although not defined : grab it from kw.



git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@10743 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d77e2bd5
...@@ -82,35 +82,28 @@ request_form = context.REQUEST.form\n ...@@ -82,35 +82,28 @@ request_form = context.REQUEST.form\n
error_message = \'\'\n error_message = \'\'\n
\n \n
# Make this script work alike wether called from another script or by a request\n # Make this script work alike wether called from another script or by a request\n
# Reinject parameters in the request\n kw.update(request_form)\n
request_form[\'dialog_method\'] = dialog_method\n
request_form[\'dialog_id\'] = dialog_id\n
request_form[\'dialog_category\'] = dialog_category\n
request_form[\'enable_pickle\'] = enable_pickle\n
# If we get unused parameters, put them in the request\n
for k, v in kw:\n
request_form[k]=v\n
\n \n
# Exceptions for UI\n # Exceptions for UI\n
if dialog_method == \'Base_configureUI\':\n if dialog_method == \'Base_configureUI\':\n
return context.Base_configureUI(form_id=request_form[\'form_id\'],\n return context.Base_configureUI(form_id=kw[\'form_id\'],\n
selection_name=request_form[\'selection_name\'],\n selection_name=kw[\'selection_name\'],\n
field_columns=request_form[\'field_columns\'],\n field_columns=kw[\'field_columns\'],\n
stat_columns=request_form[\'stat_columns\'])\n stat_columns=kw[\'stat_columns\'])\n
# Exceptions for Sort\n # Exceptions for Sort\n
if dialog_method == \'Base_configureSortOn\':\n if dialog_method == \'Base_configureSortOn\':\n
return context.Base_configureSortOn(form_id=request_form[\'form_id\'],\n return context.Base_configureSortOn(form_id=kw[\'form_id\'],\n
selection_name=request_form[\'selection_name\'],\n selection_name=kw[\'selection_name\'],\n
field_sort_on=request_form[\'field_sort_on\'],\n field_sort_on=kw[\'field_sort_on\'],\n
field_sort_order=request_form[\'field_sort_order\'])\n field_sort_order=kw[\'field_sort_order\'])\n
# Exceptions for Base_edit\n # Exceptions for Base_edit\n
# if dialog_method == \'Base_edit\':\n # if dialog_method == \'Base_edit\':\n
# return context.Base_edit(form_id=request_form[\'form_id\'],\n # return context.Base_edit(form_id=kw[\'form_id\'],\n
# dialog_id=dialog_id,\n # dialog_id=dialog_id,\n
# selection_name=request_form[\'selection_name\'])\n # selection_name=kw[\'selection_name\'])\n
# Exceptions for Workflow\n # Exceptions for Workflow\n
if dialog_method == \'Workflow_statusModify\':\n if dialog_method == \'Workflow_statusModify\':\n
value = context.Workflow_statusModify(form_id=request_form[\'form_id\'],\n value = context.Workflow_statusModify(form_id=kw[\'form_id\'],\n
dialog_id=dialog_id)\n dialog_id=dialog_id)\n
# XXX: This test is related to erp5_web and should not be present in configuration where it is not installed.\n # XXX: This test is related to erp5_web and should not be present in configuration where it is not installed.\n
if not(getattr(context.REQUEST, \'ignore_layout\', 0)) and context.getApplicableLayout() :\n if not(getattr(context.REQUEST, \'ignore_layout\', 0)) and context.getApplicableLayout() :\n
...@@ -118,38 +111,38 @@ if dialog_method == \'Workflow_statusModify\':\n ...@@ -118,38 +111,38 @@ if dialog_method == \'Workflow_statusModify\':\n
return value\n return value\n
# Exception for edit relation\n # Exception for edit relation\n
if dialog_method == \'Base_editRelation\':\n if dialog_method == \'Base_editRelation\':\n
return context.Base_editRelation(form_id=request_form[\'form_id\'],\n return context.Base_editRelation(form_id=kw[\'form_id\'],\n
field_id=request_form[\'field_id\'],\n field_id=kw[\'field_id\'],\n
selection_name=request_form[\'selection_name\'],\n selection_name=kw[\'selection_name\'],\n
selection_index=request_form[\'selection_index\'],\n selection_index=kw[\'selection_index\'],\n
uids=request_form.get(\'uids\', ()),\n uids=kw.get(\'uids\', ()),\n
listbox_uid=request_form.get(\'listbox_uid\', None),\n listbox_uid=kw.get(\'listbox_uid\', None),\n
form_pickle=request_form[\'form_pickle\'],\n form_pickle=kw[\'form_pickle\'],\n
form_signature=request_form[\'form_signature\'])\n form_signature=kw[\'form_signature\'])\n
# Exception for create relation\n # Exception for create relation\n
if dialog_method == \'Base_createRelation\':\n if dialog_method == \'Base_createRelation\':\n
return context.Base_createRelation(form_id=request_form[\'form_id\'],\n return context.Base_createRelation(form_id=kw[\'form_id\'],\n
selection_name=request_form[\'selection_name\'],\n selection_name=kw[\'selection_name\'],\n
selection_index=request_form[\'selection_index\'],\n selection_index=kw[\'selection_index\'],\n
base_category=request_form[\'base_category\'],\n base_category=kw[\'base_category\'],\n
object_uid=request_form[\'object_uid\'],\n object_uid=kw[\'object_uid\'],\n
catalog_index=request_form[\'catalog_index\'],\n catalog_index=kw[\'catalog_index\'],\n
default_module=request_form[\'default_module\'],\n default_module=kw[\'default_module\'],\n
dialog_id=dialog_id,\n dialog_id=dialog_id,\n
portal_type=request_form[\'portal_type\'],\n portal_type=kw[\'portal_type\'],\n
return_url=request_form[\'cancel_url\'])\n return_url=kw[\'cancel_url\'])\n
# Exception for folder delete\n # Exception for folder delete\n
if dialog_method == \'Folder_delete\':\n if dialog_method == \'Folder_delete\':\n
return context.Folder_delete(form_id=request_form[\'form_id\'],\n return context.Folder_delete(form_id=kw[\'form_id\'],\n
selection_name=request_form[\'selection_name\'],\n selection_name=kw[\'selection_name\'],\n
uids=request_form[\'listbox_uid\'],\n uids=kw[\'listbox_uid\'],\n
md5_object_uid_list=request_form[\'md5_object_uid_list\'])\n md5_object_uid_list=kw[\'md5_object_uid_list\'])\n
\n \n
# If the request came with a pickled form, use it as context for form object search.\n # If the request came with a pickled form, use it as context for form object search.\n
if request_form.has_key(\'pickle_string\'):\n if kw.has_key(\'pickle_string\'):\n
form_context = context.asContext(context=None,\n form_context = context.asContext(context=None,\n
portal_type=context.getPortalType(),\n portal_type=context.getPortalType(),\n
**(context.portal_selections.getObjectFromPickle(request_form[\'pickle_string\']))\n **(context.portal_selections.getObjectFromPickle(kw[\'pickle_string\']))\n
)\n )\n
else:\n else:\n
form_context = context\n form_context = context\n
...@@ -182,9 +175,9 @@ for field in form.get_fields():\n ...@@ -182,9 +175,9 @@ for field in form.get_fields():\n
# Cleanup my_ and your_ prefixes\n # Cleanup my_ and your_ prefixes\n
splitted = k.split(\'_\', 1)\n splitted = k.split(\'_\', 1)\n
if len(splitted) == 2 and splitted[0] in (\'my\', \'your\'):\n if len(splitted) == 2 and splitted[0] in (\'my\', \'your\'):\n
request_form[splitted[1]] = v\n kw[splitted[1]] = request_form[splitted[1]] = v\n
else:\n else:\n
request_form[k] = v\n kw[k] = request_form[k] = v\n
\n \n
if len(listbox_id_list):\n if len(listbox_id_list):\n
can_redirect = 0\n can_redirect = 0\n
...@@ -194,7 +187,7 @@ if len(listbox_id_list):\n ...@@ -194,7 +187,7 @@ if len(listbox_id_list):\n
# ... but handle them anyway.\n # ... but handle them anyway.\n
for listbox_id in listbox_id_list:\n for listbox_id in listbox_id_list:\n
listbox_line_list = []\n listbox_line_list = []\n
listbox = request_form[listbox_id]\n listbox = kw[listbox_id]\n
listbox_keys = listbox.keys()\n listbox_keys = listbox.keys()\n
listbox_keys.sort()\n listbox_keys.sort()\n
for key in listbox_keys:\n for key in listbox_keys:\n
...@@ -202,37 +195,37 @@ if len(listbox_id_list):\n ...@@ -202,37 +195,37 @@ if len(listbox_id_list):\n
listbox_line[\'listbox_key\'] = key\n listbox_line[\'listbox_key\'] = key\n
listbox_line_list.append(listbox_line)\n listbox_line_list.append(listbox_line)\n
listbox_line_list = tuple(listbox_line_list)\n listbox_line_list = tuple(listbox_line_list)\n
request_form[listbox_id] = listbox_line_list\n kw[listbox_id] = request_form[listbox_id] = listbox_line_list\n
\n \n
if enable_pickle or (form.update_action != \'\'):\n if enable_pickle or (form.update_action != \'\'):\n
request_form[\'pickle_string\'] = context.portal_selections.getPickle(**request_form)\n kw[\'pickle_string\'] = request_form[\'pickle_string\'] = context.portal_selections.getPickle(**kw)\n
\n \n
# Check if the selection changed\n # Check if the selection changed\n
if hasattr(request_form, \'previous_md5_object_uid_list\'):\n if hasattr(kw, \'previous_md5_object_uid_list\'):\n
selection_list = context.portal_selections.callSelectionFor(request_form[\'selection_name\'], context=context)\n selection_list = context.portal_selections.callSelectionFor(kw[\'selection_name\'], context=context)\n
if selection_list is not None:\n if selection_list is not None:\n
object_uid_list = map(lambda x:x.getObject().getUid(), selection_list)\n object_uid_list = map(lambda x:x.getObject().getUid(), selection_list)\n
error = context.portal_selections.selectionHasChanged(request_form[\'previous_md5_object_uid_list\'], object_uid_list)\n error = context.portal_selections.selectionHasChanged(kw[\'previous_md5_object_uid_list\'], object_uid_list)\n
if error:\n if error:\n
error_message = N_("Sorry+your+selection+has+changed")\n error_message = N_("Sorry+your+selection+has+changed")\n
\n \n
# if dialog_category is object_search, then edit the selection\n # if dialog_category is object_search, then edit the selection\n
if dialog_category == "object_search" :\n if dialog_category == "object_search" :\n
context.portal_selections.setSelectionParamsFor(request_form[\'selection_name\'], request_form)\n context.portal_selections.setSelectionParamsFor(kw[\'selection_name\'], kw)\n
\n \n
# if we have checked line in listbox, modify the selection\n # if we have checked line in listbox, modify the selection\n
listbox_uid = request_form.get(\'listbox_uid\', None)\n listbox_uid = kw.get(\'listbox_uid\', None)\n
if listbox_uid is not None:\n if listbox_uid is not None:\n
uids = request_form.get(\'uids\')\n uids = kw.get(\'uids\')\n
selected_uids = context.portal_selections.updateSelectionCheckedUidList(\n selected_uids = context.portal_selections.updateSelectionCheckedUidList(\n
request_form[\'selection_name\'],\n kw[\'selection_name\'],\n
listbox_uid, uids)\n listbox_uid, uids)\n
\n \n
# Remove values which doesn\'t work with make_query.\n # Remove values which doesn\'t work with make_query.\n
clean_kw = {}\n clean_kw = {}\n
for k, v in request_form.items() :\n for k, v in kw.items() :\n
if v not in (None, [], ()) :\n if v not in (None, [], ()) :\n
clean_kw[k] = request_form[k]\n clean_kw[k] = kw[k]\n
\n \n
url_params_string = make_query(clean_kw)\n url_params_string = make_query(clean_kw)\n
\n \n
...@@ -248,7 +241,7 @@ if (not(can_redirect) or len(url_params_string) > 2000) and dialog_category != " ...@@ -248,7 +241,7 @@ if (not(can_redirect) or len(url_params_string) > 2000) and dialog_category != "
# current ListBox implementation which edit Selection\'s last_url\n # current ListBox implementation which edit Selection\'s last_url\n
# with the content of REQUEST.URL\n # with the content of REQUEST.URL\n
context.REQUEST.set(\'URL\', \'%s/%s\' % (context.absolute_url(), dialog_method))\n context.REQUEST.set(\'URL\', \'%s/%s\' % (context.absolute_url(), dialog_method))\n
return dialog_form(**request_form)\n return dialog_form(**kw)\n
\n \n
if error_message != \'\':\n if error_message != \'\':\n
redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n redirect_url = \'%s/%s?%s\' % ( context.absolute_url()\n
...@@ -331,10 +324,6 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n ...@@ -331,10 +324,6 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n
<string>context</string> <string>context</string>
<string>request_form</string> <string>request_form</string>
<string>error_message</string> <string>error_message</string>
<string>_write_</string>
<string>_getiter_</string>
<string>k</string>
<string>v</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>value</string> <string>value</string>
<string>getattr</string> <string>getattr</string>
...@@ -348,10 +337,14 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n ...@@ -348,10 +337,14 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n
<string>MARKER</string> <string>MARKER</string>
<string>listbox_id_list</string> <string>listbox_id_list</string>
<string>file_id_list</string> <string>file_id_list</string>
<string>_getiter_</string>
<string>field</string> <string>field</string>
<string>k</string>
<string>v</string>
<string>hasattr</string> <string>hasattr</string>
<string>splitted</string> <string>splitted</string>
<string>len</string> <string>len</string>
<string>_write_</string>
<string>log</string> <string>log</string>
<string>listbox_id</string> <string>listbox_id</string>
<string>listbox_line_list</string> <string>listbox_line_list</string>
...@@ -367,7 +360,6 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n ...@@ -367,7 +360,6 @@ return context.REQUEST.RESPONSE.redirect(redirect_url)\n
<string>N_</string> <string>N_</string>
<string>listbox_uid</string> <string>listbox_uid</string>
<string>uids</string> <string>uids</string>
<string>selection_name</string>
<string>selected_uids</string> <string>selected_uids</string>
<string>clean_kw</string> <string>clean_kw</string>
<string>url_params_string</string> <string>url_params_string</string>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment