From ff15467ec84a5bbb2686b1da33ee4e531689ac59 Mon Sep 17 00:00:00 2001 From: Yusei Tahara <yusei@nexedi.com> Date: Wed, 8 Aug 2007 08:09:30 +0000 Subject: [PATCH] sorry, my previous changes has a problem. I revert my changes. git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15545 20353a03-c40f-0410-a6d1-a30d3c3de9de --- .../portal_skins/erp5_core/Base_edit.xml | 18 +++++++++- product/ERP5Form/ListBox.py | 34 +------------------ 2 files changed, 18 insertions(+), 34 deletions(-) diff --git a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.xml b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.xml index 15abe1b87e..40065dfffd 100644 --- a/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.xml +++ b/product/ERP5/bootstrap/erp5_core/SkinTemplateItem/portal_skins/erp5_core/Base_edit.xml @@ -107,6 +107,19 @@ except FormValidationError, validation_errors:\n value(request)\n return form(request)\n \n +def editListBox(listbox_field, listbox):\n + """ Function called to edit a listbox\n + """\n + if listbox is not None:\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 + v.update(gv)\n + context.restrictedTraverse(url).edit(**v)\n +\n def editMatrixBox(matrixbox_field, matrixbox):\n """ Function called to edit a Matrix box\n """\n @@ -212,7 +225,9 @@ try:\n # then we edit them\n for field in form.get_fields():\n parseField(field)\n - if(field.meta_type == \'MatrixBox\'):\n + if(field.meta_type == \'ListBox\'):\n + editListBox(field, request.get(field.id))\n + elif(field.meta_type == \'MatrixBox\'):\n editMatrixBox(field, request.get(field.id))\n \n # Maybe we should build a list of objects we need\n @@ -315,6 +330,7 @@ return request[\'RESPONSE\'].redirect(redirect_url)\n <string>field_id</string> <string>value</string> <string>callable</string> + <string>editListBox</string> <string>editMatrixBox</string> <string>MARKER</string> <string>kw</string> diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py index 57762eb581..a047c49de6 100644 --- a/product/ERP5Form/ListBox.py +++ b/product/ERP5Form/ListBox.py @@ -2997,42 +2997,10 @@ class ListBoxValidator(Validator.Validator): LOG("ListBox FormValidationError",0,str(error_result)) LOG("ListBox FormValidationError",0,str(errors)) raise FormValidationError(errors, error_result) - - return ListBoxEditor(field, result) + return result ListBoxValidatorInstance = ListBoxValidator() -class ListBoxEditor: - """ - A class holding all values required to update objects - """ - - def __init__(self, field, update_dict): - self.field = field - self.update_dict = update_dict - - def view(self): - return self.__dict__ - - def __call__(self, REQUEST): - pass - - def edit(self, context): - if self.update_dict is not None: - gv = {} - if self.field.has_value('global_attributes'): - hidden_attributes = map(lambda x:x[0], self.field.get_value('global_attributes')) - for k in hidden_attributes: - gv[k] = getattr(request, k, None) - for url, v in self.update_dict.items(): - v.update(gv) - ## XXX security check is needed. - ## XXX we need to make restricted version of edit method. - self.field.restrictedTraverse(url).edit(**v) - -allow_class(ListBoxEditor) - - class ListBox(ZMIField): meta_type = "ListBox" -- 2.30.9