[Checkins] SVN: zope3org/trunk/src/zorg/multiform/

Stefan Martin s.martin at iwm-kmrc.de
Mon Apr 10 13:33:36 EDT 2006


Log message for revision 66801:
  

Changed:
  U   zope3org/trunk/src/zorg/multiform/gridform.py
  U   zope3org/trunk/src/zorg/multiform/gridform.txt
  U   zope3org/trunk/src/zorg/multiform/multiform.py

-=-
Modified: zope3org/trunk/src/zorg/multiform/gridform.py
===================================================================
--- zope3org/trunk/src/zorg/multiform/gridform.py	2006-04-10 17:27:54 UTC (rev 66800)
+++ zope3org/trunk/src/zorg/multiform/gridform.py	2006-04-10 17:33:35 UTC (rev 66801)
@@ -30,9 +30,9 @@
         self.request.form[self.key]=v
 
     def _getSelected(self):
-        self.request.form.get(self.key,False)
+        return self.request.form.get(self.key,False)
 
-    selected = property(_getSelected,_setSelected)
+    selected = property(_getSelected ,_setSelected)
         
 
 class FormLocationProxy(ProxyBase):

Modified: zope3org/trunk/src/zorg/multiform/gridform.txt
===================================================================
--- zope3org/trunk/src/zorg/multiform/gridform.txt	2006-04-10 17:27:54 UTC (rev 66800)
+++ zope3org/trunk/src/zorg/multiform/gridform.txt	2006-04-10 17:33:35 UTC (rev 66801)
@@ -25,7 +25,7 @@
     ...         self.name = name
     ...         self.__name__= name
 
-    >>> orderMapping = dict([(str(k),Order(k,name='n%s'%k)) for k in range(2)])
+    >>> orderMapping = dict([('n%s'%k,Order(k,name='n%s'%k)) for k in range(2)])
 
 Now we use the ``GridForm`` as a base class to display orders in
 tabular form. Additionally to the IOrder schema the ISelection schema
@@ -34,14 +34,23 @@
 
 
     >>> def isSelectedInput(form,action):
-    ...     if not form.parentForm.inputMode:
+    ...     if not isSubFormInputMode(form,action):
     ...         return False
     ...     return ISelection(form.context).selected
 
-	>>> def isFormDisplayMode(form,action):
+    >>> def isSelectedDisplay(form,action):
+    ...     if isSubFormInputMode(form,action):
+    ...         return False
+    ...     return ISelection(form.context).selected
+    
+	>>> def isSubFormInputMode(form,action):
 	...     parentForm = form.parentForm
-	...     return (parentForm.subFormInputMode.get(form.context.__name__,parentForm.inputMode)
+	...     return parentForm.subFormInputMode.get(form.context.__name__,
+	...     parentForm.inputMode)
 
+	>>> def isSubFormDisplayMode(form,action):
+	...		return not isSubFormInputMode(form,action)
+
     >>> class OrderForm(gridform.GridItemFormBase):
     ...     inputMode=False
     ...     forceInput=['selected']
@@ -60,12 +69,12 @@
     ...     def handle_save_action(self, action, data):
     ...         form.applyChanges(self.context, self.form_fields,
     ...         data, self.adapters)
-    ...         self.parentForm.subFormNewInputMode[self.name]=False
+    ...         self.parentForm.subFormNewInputMode[self.context.__name__]=False
     ...         
     ...     @multiform.parentAction('Edit',
-    ...         condition=multiform.isParentFormDisplayMode)
+    ...         condition=isSelectedDisplay)
     ...     def handle_edit_action(self, action, data):
-    ...         self.parentForm.subFormNewInputMode[self.name]=True
+    ...         self.parentForm.subFormNewInputMode[self.context.__name__]=True
 
 
     >>> class OrdersForm(gridform.GridFormBase):
@@ -91,13 +100,13 @@
     >>> request = TestRequest()
     >>> gf = OrdersForm(orderMapping,request)
     >>> print gf()
-    <div>
-    <div><input ... name="form.0.selected" type="checkbox" ...  /></div>
+    <div>a
+    <div><input ... name="form.n0.selected" type="checkbox" ...  /></div>
     <div>0</div>
     <div>n0</div>
     </div>
     <div>
-    <div><input ... name="form.1.selected" type="checkbox" ...  /></div>
+    <div><input ... name="form.n1.selected" type="checkbox" ...  /></div>
     <div>1</div>
     <div>n1</div>
     </div>
@@ -105,12 +114,12 @@
 Now we are going to select some items. And the checkbox of the ``selected``
 
     >>> request = TestRequest()
-    >>> request.form['form.1.selected']=u'on'
+    >>> request.form['form.n1.selected']=u'on'
     >>> gf = OrdersForm(orderMapping,request)
     >>> print gf()
-    <div>
+    <div>a
     ...
-    <div><input ... checked="checked" ... name="form.1.selected" ...</div>
+    <div><input ... checked="checked" ... name="form.n1.selected" ...</div>
     <div>1</div>
     <div>n1</div>
     </div>
@@ -119,7 +128,7 @@
 input mode. 
 
     >>> request.form['form.actions.edit']=u''
-    >>> request.form['form.0.selected.used']=u''
+    >>> request.form['form.n0.selected.used']=u''
     >>> gf = OrdersForm(orderMapping,request)
     >>> print gf()
 

Modified: zope3org/trunk/src/zorg/multiform/multiform.py
===================================================================
--- zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-10 17:27:54 UTC (rev 66800)
+++ zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-10 17:33:35 UTC (rev 66801)
@@ -139,7 +139,8 @@
         hasErrors = False
         for form in self.subForms.values():
             form.update()
-            hasErrors = hasErrors or form.errors
+            if form.errors is not None:
+                hasErrors = hasErrors or form.errors
         if hasErrors:
             self.subFormNewInputMode = {}
         if len(self.subFormNewInputMode) > 0:
@@ -166,6 +167,7 @@
             self.subForms[name] = subForm
 
     def setUpForms(self, *args, **kw):
+
         for name,item in self.context.items():
             inputMode = self.subFormInputMode.get(name, self.inputMode)
             self.setUpForm(name, item, inputMode)



More information about the Checkins mailing list