[Checkins] SVN: z3ext.layoutform/trunk/src/z3ext/layoutform/

Nikolay Kim fafhrd at datacom.kz
Tue Dec 16 07:34:00 EST 2008


Log message for revision 94118:
  

Changed:
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py

-=-
Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt	2008-12-16 11:59:06 UTC (rev 94117)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt	2008-12-16 12:34:00 UTC (rev 94118)
@@ -1,6 +1,9 @@
 <div class="z-form-fieldset">
-  <h3 tal:content="context/label"></h3>
-  <div class="z-page-description" tal:content="context/description|nothing"></div>
+  <h3 class="z-form-grouplabel"
+      tal:content="context/label" tal:condition="context/label"></h3>
+  <div class="z-form-description" 
+       tal:condition="context/description|nothing"
+       tal:content="context/description|nothing"></div>
 
   <tal:block tal:repeat="widget context/widgets/values"
        tal:content="structure widget/@@pagelet/layoutform.widget" />

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py	2008-12-16 11:59:06 UTC (rev 94117)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/textarea.py	2008-12-16 12:34:00 UTC (rev 94118)
@@ -28,7 +28,7 @@
 class TextAreaWidget(textarea.TextAreaWidget):
     """Textarea widget implementation."""
 
-    rows = 6
+    rows = 5
 
 
 @component.adapter(schema.interfaces.IField, ILayoutFormLayer)
@@ -36,17 +36,3 @@
 def TextAreaFieldWidget(field, request):
     """IFieldWidget factory for TextWidget."""
     return FieldWidget(field, TextAreaWidget(request))
-
-
-
-class DescriptionWidget(textarea.TextAreaWidget):
-    """Textarea widget implementation."""
-
-    rows = 4
-
-
- at component.adapter(schema.interfaces.IField, ILayoutFormLayer)
- at interface.implementer(interfaces.IFieldWidget)
-def DescriptionFieldWidget(field, request):
-    """IFieldWidget factory for TextWidget."""
-    return FieldWidget(field, DescriptionWidget(request))

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	2008-12-16 11:59:06 UTC (rev 94117)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	2008-12-16 12:34:00 UTC (rev 94118)
@@ -97,6 +97,9 @@
         groups = []
         subforms = []
         for form in self._loadSubforms():
+            if not form.isAvailable():
+                continue
+
             form.update()
 
             if IGroup.providedBy(form):
@@ -123,13 +126,14 @@
         if not IPageletSubform.providedBy(self):
             self.actions.execute()
 
-        for form in self.groups:
-            form.postUpdate()
         for form in self.subforms:
             form.postUpdate()
         for form in self.forms:
             form.postUpdate()
 
+    def isAvailable(self):
+        return True
+
     def postUpdate(self):
         self.actions.execute()
 

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-12-16 11:59:06 UTC (rev 94117)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/interfaces.py	2008-12-16 12:34:00 UTC (rev 94118)
@@ -79,7 +79,10 @@
 class IPageletEditSubForm(IPageletBaseForm):
     """ Sub form mixin for pagelet implementation."""
 
+    def executeActions(form):
+        """Execute form actions."""
 
+
 class IPageletSubform(interface.Interface):
     """ Subform """
 
@@ -89,6 +92,9 @@
         default = 9999,
         required = False)
 
+    def isAvailable():
+        """If subform available."""
+
     def postUpdate():
         """Update form after manager form updated."""
 

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py	2008-12-16 11:59:06 UTC (rev 94117)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/subform.py	2008-12-16 12:34:00 UTC (rev 94118)
@@ -21,7 +21,7 @@
 from zope.lifecycleevent import ObjectModifiedEvent
 
 from z3c.form import subform, button
-from z3c.form.interfaces import IActionHandler
+from z3c.form.interfaces import ISubForm, IActionHandler
 from z3ext.statusmessage.interfaces import IStatusMessage
 
 from utils import applyChanges
@@ -49,25 +49,31 @@
             changed = applyChanges(self, content, data)
             if changed:
                 event.notify(ObjectModifiedEvent(content))
-                IStatusMessage(self.request).add(self.successMessage)
-            else:
-                IStatusMessage(self.request).add(self.noChangesMessage)
 
-    def executeActions(self):
+    def executeActions(self, form):
         request = self.request
         content = self.getContent()
 
-        for action in self.parentForm.actions.executedActions:
-            adapter = queryMultiAdapter(
-                (self, request, content, action), IActionHandler)
-            if adapter:
-                adapter()
+        if hasattr(form, 'actions'):
+            for action in form.actions.executedActions:
+                adapter = queryMultiAdapter(
+                    (self, request, content, action), IActionHandler)
+                if adapter:
+                    adapter()
 
+        if ISubForm.providedBy(form):
+            self.executeActions(form.parentForm)
+        elif IPageletSubform.providedBy(form) and form.managers:
+            self.executeActions(form.managers[0])
+
     def update(self):
         self.updateWidgets()
-        
+
         if not IPageletSubform.providedBy(self):
-            self.executeActions()
+            self.executeActions(self.parentForm)
 
+    def isAvailable(self):
+        return True
+
     def postUpdate(self):
-        self.executeActions()        
+        self.executeActions(self.parentForm)



More information about the Checkins mailing list