[Erp5-report] r15536 - /erp5/trunk/products/ERP5Form/ListBox.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Aug 7 18:12:06 CEST 2007


Author: yusei
Date: Tue Aug  7 18:12:06 2007
New Revision: 15536

URL: http://svn.erp5.org?rev=15536&view=rev
Log:
Moved edit function from Base_edit script and added as ListBoxEditor class.

Modified:
    erp5/trunk/products/ERP5Form/ListBox.py

Modified: erp5/trunk/products/ERP5Form/ListBox.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/ListBox.py?rev=15536&r1=15535&r2=15536&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/ListBox.py (original)
+++ erp5/trunk/products/ERP5Form/ListBox.py Tue Aug  7 18:12:06 2007
@@ -2997,9 +2997,39 @@
             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"




More information about the Erp5-report mailing list