[Checkins] SVN: zope3org/trunk/src/zorg/multiform/ moved form_fields back to class

Bernd Dorn bernd.dorn at fhv.at
Mon Apr 10 13:27:55 EDT 2006


Log message for revision 66800:
  moved form_fields back to class

Changed:
  U   zope3org/trunk/src/zorg/multiform/actions.txt
  U   zope3org/trunk/src/zorg/multiform/configure.zcml
  U   zope3org/trunk/src/zorg/multiform/grid.pt
  U   zope3org/trunk/src/zorg/multiform/multiform.py

-=-
Modified: zope3org/trunk/src/zorg/multiform/actions.txt
===================================================================
--- zope3org/trunk/src/zorg/multiform/actions.txt	2006-04-10 17:01:51 UTC (rev 66799)
+++ zope3org/trunk/src/zorg/multiform/actions.txt	2006-04-10 17:27:54 UTC (rev 66800)
@@ -33,12 +33,9 @@
 
     >>> class OrderForm(ItemFormBase):
     ...     inputMode=False
-    ...     
-    ...     def __init__(self,context,request,parentForm):
-    ...         super(OrderForm,self).__init__(context,request,parentForm)
-    ...         self.form_fields = form.Fields(IOrder,omit_readonly=False,
+    ...     form_fields = form.Fields(IOrder,omit_readonly=False,
     ...         render_context=True)
-    ...         
+    ...     
     ...     @multiform.parentAction(u"Save",
     ...     condition=multiform.isParentFormInputMode,inputMode=True)
     ...     def handle_save_action(self, action, data):

Modified: zope3org/trunk/src/zorg/multiform/configure.zcml
===================================================================
--- zope3org/trunk/src/zorg/multiform/configure.zcml	2006-04-10 17:01:51 UTC (rev 66799)
+++ zope3org/trunk/src/zorg/multiform/configure.zcml	2006-04-10 17:27:54 UTC (rev 66800)
@@ -3,8 +3,17 @@
            xmlns:i18n="http://namespaces.zope.org/i18n"
            i18n_domain="zope">
 
- <adapter for="zope.app.location.interfaces.ILocation"
+ <adapter for="zope.app.location.interfaces.ILocation
+               zope.formlib.interfaces.IForm"
+          provides=".interfaces.IFormLocation"
+          factory=".gridform.FormLocationProxy"
+          />
+
+ <adapter for=".interfaces.IFormLocation"
           provides=".interfaces.ISelection"
-          factory=".gridform.LocationSelection"/>
+          factory=".gridform.FormLocationSelection"
+          />
+
+ <include package=".container"/>
  
 </configure>
\ No newline at end of file

Modified: zope3org/trunk/src/zorg/multiform/grid.pt
===================================================================
--- zope3org/trunk/src/zorg/multiform/grid.pt	2006-04-10 17:01:51 UTC (rev 66799)
+++ zope3org/trunk/src/zorg/multiform/grid.pt	2006-04-10 17:27:54 UTC (rev 66800)
@@ -1,4 +0,0 @@
-<html metal:extend-macro="context/@@standard_macros/view"
-      metal:define-macro="main">
-</html>
-

Modified: zope3org/trunk/src/zorg/multiform/multiform.py
===================================================================
--- zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-10 17:01:51 UTC (rev 66799)
+++ zope3org/trunk/src/zorg/multiform/multiform.py	2006-04-10 17:27:54 UTC (rev 66800)
@@ -6,7 +6,10 @@
 from zope.formlib import form
 from zope.formlib.interfaces import IBoundAction
 from zope.formlib.i18n import _
-from interfaces import IMultiForm, IParentAction, IItemAction, IFormLocation,IItemForm
+from interfaces import IMultiForm, IParentAction, IItemAction
+from interfaces import IFormLocation,IItemForm
+import copy
+
 from zope import interface
         
 
@@ -90,8 +93,13 @@
     parentForm = None
     inputMode = None
     newInputMode = None
+    form_fields=[]
+    actions = []
 
     def __init__(self,context,request,parentForm):
+        # we have to copy the default fields, so that we can mutate
+        # them in our instance
+        self.__dict__['form_fields']=copy.deepcopy(self.__class__.form_fields)
         self.request=request
         self.context = getMultiAdapter([context,self],IFormLocation)
         self.parentForm=parentForm
@@ -121,7 +129,8 @@
     newInputMode = None
     subFormInputMode = {}
     subFormNewInputMode = {}
-
+    actions = []
+    
     def update(self):
         self.initInputMode()
         self.checkInputMode()
@@ -146,7 +155,7 @@
 
     def setUpForm(self, name, item, inputMode, *args, **kw):
             prefix = (self.prefix and self.prefix+'.' or '') + name
-            subForm = self.itemFormFactory(item,self.request,self)
+            subForm = self.newSubForm(item)
             if inputMode is not None and not inputMode:
                 forceInput = self.itemFormFactory.forceInput
                 for field in subForm.form_fields:
@@ -206,7 +215,7 @@
         if len(self.context) > 0:
             for name, item in self.context.items():
                 break
-            tmpForm = self.itemFormFactory(item,self.request,self)
+            tmpForm = self.newSubForm(item)
             for field in tmpForm.form_fields:
                 if not field.for_display and field.__name__ not in tmpForm.forceInput:
                     inputField = field
@@ -215,3 +224,9 @@
                 prefix = self.prefix + '.' + name + '.' + field.__name__
                 self.subFormInputMode[name] = (prefix in self.request.form)
 
+    def newSubForm(self,item):
+
+        """creates a new instance from teh itemFormFactory for
+        temporary usage"""
+        
+        return self.itemFormFactory(item,self.request,self)



More information about the Checkins mailing list