From 50786ab86323e213e0392639924ced7ac3644ff8 Mon Sep 17 00:00:00 2001
From: Yusei Tahara <yusei@nexedi.com>
Date: Tue, 7 Aug 2007 16:12:06 +0000
Subject: [PATCH] Moved edit function from Base_edit script and added as
 ListBoxEditor class.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15536 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Form/ListBox.py | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/product/ERP5Form/ListBox.py b/product/ERP5Form/ListBox.py
index a047c49de6..297a2feea8 100644
--- a/product/ERP5Form/ListBox.py
+++ b/product/ERP5Form/ListBox.py
@@ -2997,10 +2997,40 @@ class ListBoxValidator(Validator.Validator):
             LOG("ListBox FormValidationError",0,str(error_result))
             LOG("ListBox FormValidationError",0,str(errors))
             raise FormValidationError(errors, error_result)
-        return result
+
+        return ListBoxEditor(field, 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)
+        self.field.restrictedTraverse(url).edit(**v)
+
+allow_class(ListBoxEditor)
+
+
 class ListBox(ZMIField):
   meta_type = "ListBox"
 
-- 
2.30.9