[Checkins] SVN: z3c.multiform/Sandbox/src/z3c/multiform/ Test of form_reset in update. This allow to call setUpWidgets() outside before update().

Stefan Martin s.martin at iwm-kmrc.de
Mon Feb 5 08:10:13 EST 2007


Log message for revision 72366:
  Test of form_reset in update. This allow to call setUpWidgets() outside before update().
  

Changed:
  U   z3c.multiform/Sandbox/src/z3c/multiform/interfaces.py
  U   z3c.multiform/Sandbox/src/z3c/multiform/multiform.py

-=-
Modified: z3c.multiform/Sandbox/src/z3c/multiform/interfaces.py
===================================================================
--- z3c.multiform/Sandbox/src/z3c/multiform/interfaces.py	2007-02-04 16:38:33 UTC (rev 72365)
+++ z3c.multiform/Sandbox/src/z3c/multiform/interfaces.py	2007-02-05 13:10:10 UTC (rev 72366)
@@ -7,6 +7,7 @@
 class IMultiForm(Interface):
     """multiform"""
 
+
 class IItemForm(Interface):
     """a sub form for an item of a multiform"""
 
@@ -20,7 +21,7 @@
 
 
 class IItemAction(IAction):
-    """a item action"""
+    """an item action"""
 
     
 class IParentAction(IAction):

Modified: z3c.multiform/Sandbox/src/z3c/multiform/multiform.py
===================================================================
--- z3c.multiform/Sandbox/src/z3c/multiform/multiform.py	2007-02-04 16:38:33 UTC (rev 72365)
+++ z3c.multiform/Sandbox/src/z3c/multiform/multiform.py	2007-02-05 13:10:10 UTC (rev 72366)
@@ -280,8 +280,15 @@
         super(MultiFormBase,self).__init__(context, request)
         self.filter = self.context
 
-    def setUpWidgets(self, *args, **kw):
-        super(MultiFormBase,self).setUpWidgets(*args,**kw)
+    def setUpSubWidgets(self):
+        self.forms = list(self.filter.keys())
+        self.checkInputMode()
+        self.updateSelection()                
+
+    def setUpWidgets(self, ignore_request=False):
+        if not ignore_request:
+            self.setUpSubWidgets()
+        super(MultiFormBase,self).setUpWidgets(ignore_request=ignore_request)
         self.setUpForms(*args, **kw)
 
     def setUpForm(self, name, item, inputMode, *args, **kw):
@@ -412,10 +419,34 @@
                 yield action
 
     def update(self):
-        self.forms = list(self.filter.keys())
-        self.checkInputMode()
-        self.updateSelection()
-        super(MultiFormBase,self).update()
+        if self.form_reset:
+            self.setUpWidgets()
+            self.form_reset = False
+
+        data = {}
+        errors, action = handleSubmit(self.actions, data, self.validate)
+        # the following part will make sure that previous error not
+        # get overriden by new errors. This is usefull for subforms. (ri)
+        if self.errors is None:
+            self.errors = errors
+        else:
+            if errors is not None:
+                self.errors += tuple(errors)
+
+        if errors:
+            self.status = _('There were errors')
+            result = action.failure(data, errors)
+        elif errors is not None:
+            self.form_reset = True
+            result = action.success(data)
+        else:
+            result = None
+
+        self.form_result = result        
+#        self.forms = list(self.filter.keys())
+#        self.checkInputMode()
+#        self.updateSelection()
+#        super(MultiFormBase,self).update()
         # either (form update or errors) or (subforms update)
         if not (self.form_reset or self.errors):
             for key in self.forms:



More information about the Checkins mailing list