[Checkins] SVN: z3ext.layoutform/trunk/ Use new pagelet api for rendering widgets

Nikolay Kim fafhrd at datacom.kz
Fri Dec 19 16:53:01 EST 2008


Log message for revision 94205:
  Use new pagelet api for rendering widgets

Changed:
  U   z3ext.layoutform/trunk/CHANGES.txt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisp.pt
  D   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisplay.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt
  D   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formview.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt
  D   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspacedisp.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/interfaces.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.pt
  A   z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py
  U   z3ext.layoutform/trunk/src/z3ext/layoutform/form.py

-=-
Modified: z3ext.layoutform/trunk/CHANGES.txt
===================================================================
--- z3ext.layoutform/trunk/CHANGES.txt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/CHANGES.txt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -11,7 +11,9 @@
 
 - Use button.handler instead of buttonAndHandler
 
+- Use new pagelet api for rendering widgets
 
+
 1.2.8 (2008-11-21)
 ------------------
 

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/configure.zcml	2008-12-19 21:53:01 UTC (rev 94205)
@@ -54,6 +54,13 @@
      permission="zope.Public" />
 
   <z3ext:pagelet
+     template="formdisp.pt"
+     for="..interfaces.IPageletDisplayForm"
+     layer="..interfaces.ILayoutFormLayer"
+     provides="..interfaces.IPageletFormView"
+     permission="zope.Public" />
+
+  <z3ext:pagelet
      template="subform.pt"
      for="z3c.form.interfaces.ISubForm"
      layer="..interfaces.ILayoutFormLayer"
@@ -87,19 +94,17 @@
      layer="..interfaces.ILayoutFormLayer"
      permission="zope.Public" />
 
-  <z3ext:pagelet
-     for="..interfaces.IPageletDisplayForm"
-     template="formdisplay.pt"
-     provides="z3ext.layoutform.browser.interfaces.IForm"
-     layer="..interfaces.ILayoutFormLayer"
-     permission="zope.Public" />
-
   <!-- viewspace view -->
   <interface
      name="layoutform.viewspace"
      type="z3ext.layout.interfaces.IPageletType"
      interface="z3ext.layoutform.browser.interfaces.IViewspace" />
 
+  <interface
+     name="layoutform.viewspaceInfo"
+     type="z3ext.layout.interfaces.IPageletType"
+     interface="z3ext.layoutform.browser.interfaces.IExtraViewspaceInfo" />
+
   <z3ext:pagelet
      for="..interfaces.IPageletForm"
      template="formviewspace.pt"
@@ -107,13 +112,6 @@
      layer="..interfaces.ILayoutFormLayer"
      permission="zope.Public" />
 
-  <z3ext:pagelet
-     for="..interfaces.IPageletDisplayForm"
-     template="formviewspacedisp.pt"
-     provides="z3ext.layoutform.browser.interfaces.IViewspace"
-     layer="..interfaces.ILayoutFormLayer"
-     permission="zope.Public" />
-
   <!-- form buttons -->
   <interface
      name="layoutform.buttons"
@@ -130,55 +128,26 @@
   <!-- widget view -->
   <interface
      name="layoutform.widget"
-     type="z3ext.layout.interfaces.IPageletType"
+     type="z3ext.layout.interfaces.IPageletManagerType"
      interface="z3ext.layoutform.browser.interfaces.IWidget" />
 
   <z3ext:pagelet
      for="z3c.form.interfaces.IWidget"
-     template="widget.pt"
+     manager="zope.schema.interfaces.IField z3c.form.interfaces.IForm"
      provides="z3ext.layoutform.browser.interfaces.IWidget"
-     layer="..interfaces.ILayoutFormLayer"
+     template="widget.pt"
      permission="zope.Public" />
 
-  <!-- display widget view -->
-  <interface
-     name="layoutform.widgetDisplay"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IWidgetDisplay" />
+  <adapter factory=".widget.getWidgetManager" />
 
+  <!-- display widget view -->
   <z3ext:pagelet
      for="z3c.form.interfaces.IWidget"
+     manager="zope.schema.interfaces.IField z3c.form.interfaces.IDisplayForm"
+     provides="z3ext.layoutform.browser.interfaces.IWidget"
      template="widgetDisplay.pt"
-     provides="z3ext.layoutform.browser.interfaces.IWidgetDisplay"
-     layer="..interfaces.ILayoutFormLayer"
      permission="zope.Public" />
 
-  <!-- group view -->
-  <interface
-     name="layoutform.group"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IGroup" />
-
-  <z3ext:pagelet
-     for="z3c.form.interfaces.IGroup"
-     template="formgroup.pt"
-     provides="z3ext.layoutform.browser.interfaces.IGroup"
-     layer="..interfaces.ILayoutFormLayer"
-     permission="zope.Public" />
-
-  <!-- groups view -->
-  <interface
-     name="layoutform.groups"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IFormGroups" />
-
-  <z3ext:pagelet
-     for="..interfaces.IPageletForm"
-     template="formgroups.pt"
-     provides="z3ext.layoutform.browser.interfaces.IFormGroups"
-     layer="..interfaces.ILayoutFormLayer"
-     permission="zope.Public" />
-
   <!-- add form buttons -->
   <z3ext:pagelet
      for="..interfaces.IPageletAddForm"
@@ -187,42 +156,10 @@
      layer="..interfaces.ILayoutFormLayer"
      permission="zope.Public" />
 
-  <!-- extra form views -->
-  <interface
-     name="layoutform.formInfo"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IExtraFormInfo" />
-
-  <interface
-     name="layoutform.formGroups"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IFormGroups" />
-
-  <interface
-     name="layoutform.viewspaceInfo"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IExtraViewspaceInfo" />
-
-  <interface
-     name="layoutform.widgetBefore"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IExtraBeforeWidget" />
-
-  <interface
-     name="layoutform.widgetAfter"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IExtraAfterWidget" />
-
-  <interface
-     name="layoutform.buttonsInfo"
-     type="z3ext.layout.interfaces.IPageletType"
-     interface="z3ext.layoutform.browser.interfaces.IExtraFormButtonsInfo" />
-
   <!-- styles -->
   <z3ext:resourceinclude
      name="z3ext-layoutform.css"
-     library="z3ext"
-     type="stylesheet"
+     library="z3ext" type="stylesheet"
      file="styles.css" filetype="zrt" />
 
   <z3ext:resource

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/form.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -2,5 +2,5 @@
      tal:content="structure context/@@pagelet/layoutform.form">
 </div>
 
-<tal:block tal:repeat="form context/forms"
-	   tal:content="structure form/@@pagelet/layoutform.form" />
+<tal:block tal:repeat="context context/forms"
+	   tal:content="structure pagelet:form" />

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formbuttons.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -1,7 +1,4 @@
 <div class="z-form-controls" tal:condition="context/actions|nothing">
-  <tal:block tal:content="structure
-             context/@@pagelet/layoutform.buttonsInfo|nothing" />
-
   <span tal:condition="context/actions/values">
     <hr />
     <input tal:repeat="action context/actions/values"

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisp.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisp.pt	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisp.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -0,0 +1,3 @@
+<div class="z-form-display"
+     tal:content="structure context/@@pagelet/layoutform.form">
+</div>

Deleted: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisplay.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisplay.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formdisplay.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -1,2 +0,0 @@
-<tal:block tal:content="structure context/@@pagelet/layoutform.formInfo|nothing" />
-<tal:block tal:content="structure context/@@pagelet/layoutform.viewspace" />

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroup.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -4,7 +4,7 @@
   <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" />
+  
+  <tal:block tal:repeat="context context/widgets/values"
+	     tal:content="structure pagelet:layoutform.widget" />
 </div>

Deleted: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formgroups.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -1,3 +0,0 @@
-<tal:block
-   tal:repeat="form context/forms"
-   tal:content="structure form/@@pagelet/layoutform.form|nothing" />

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formview.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formview.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formview.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -6,8 +6,6 @@
 		      action context/action;
 		      name context/name;
 		      id context/id">
-
-  <tal:block tal:content="structure context/@@pagelet/layoutform.formInfo|nothing" />
   <tal:block tal:content="structure context/@@pagelet/layoutform.viewspace" />
   <tal:block tal:content="structure context/@@pagelet/layoutform.buttons" />
 </form>

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspace.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -3,12 +3,11 @@
 <div class="z-form-description"
      tal:condition="context/description" tal:content="context/description"></div>
 
-<tal:block tal:content="structure
-           context/@@pagelet/layoutform.viewspaceInfo|nothing" />
+<tal:block tal:content="structure pagelet:layoutform.viewspaceInfo" />
 
 <div class="z-form-fieldset" tal:condition="context/widgets">
-  <tal:block tal:repeat="widget context/widgets/values"
-       tal:content="structure widget/@@pagelet/layoutform.widget" />
+  <tal:block tal:repeat="context context/widgets/values"
+	     tal:content="structure pagelet:layoutform.widget" />
 </div>
 
 <tal:block tal:condition="context/groups|nothing"

Deleted: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspacedisp.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspacedisp.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/formviewspacedisp.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -1,16 +0,0 @@
-<h1 tal:condition="context/label|nothing"
-    tal:content="context/label|nothing">Do something</h1>
-<div class="z-form-description" 
-     tal:condition="context/description|nothing"
-     tal:content="context/description|nothing"></div>
-
-<tal:block tal:content="structure
-           context/@@pagelet/layoutform.viewspaceInfo|nothing" />
-
-<div class="z-form-fieldset" tal:condition="context/widgets">
-  <tal:block tal:repeat="widget context/widgets/values"
-       tal:content="structure widget/@@pagelet/layoutform.widgetDisplay" />
-</div>
-
-<tal:block tal:condition="context/groups|nothing"
-	   tal:content="structure context/@@pagelet/layoutform.formGroups|nothing" />

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/interfaces.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/interfaces.py	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/interfaces.py	2008-12-19 21:53:01 UTC (rev 94205)
@@ -22,10 +22,6 @@
     """ form view """
 
 
-class IExtraFormInfo(interface.Interface):
-    """ extra form information """
-
-
 class IViewspace(interface.Interface):
     """ form viewspace """
 
@@ -38,29 +34,5 @@
     """ widget view """
 
 
-class IWidgetDisplay(interface.Interface):
-    """ dispaly widget view """
-
-
-class IExtraBeforeWidget(interface.Interface):
-    """ extra widget information """
-
-
-class IExtraAfterWidget(interface.Interface):
-    """ extra widget information """
-
-
-class IGroup(interface.Interface):
-    """ group """
-
-
-class IFormGroups(interface.Interface):
-    """ form groups """
-
-
 class IFormButtons(interface.Interface):
     """ form buttons """
-
-
-class IExtraFormButtonsInfo(interface.Interface):
-    """ extra buttons information """

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/subform.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -4,6 +4,6 @@
   <div class="z-form-description"
        tal:condition="context/description" tal:content="context/description"></div>
 
-  <tal:block tal:repeat="widget context/widgets/values"
-       tal:content="structure widget/@@pagelet/layoutform.widget" />
+  <tal:block tal:repeat="context context/widgets/values"
+	     tal:content="structure pagelet:layoutform.widget" />
 </div>

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.pt
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.pt	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.pt	2008-12-19 21:53:01 UTC (rev 94205)
@@ -1,7 +1,6 @@
 <div class="z-form-field"
      tal:define="error context/error|nothing"
      tal:attributes="class python:error and'z-form-field error'or'z-form-field'">
-  <tal:block tal:content="structure context/@@pagelet/layoutform.widgetBefore|nothing" />
   <label tal:attributes="for context/id;
 			 title context/field/description"
 	 tal:content="context/label">The Label</label>
@@ -15,5 +14,4 @@
   <div tal:content="structure context/render">
     <input type="text" style="width:100%" />
   </div>
-  <tal:block tal:content="structure context/@@pagelet/layoutform.widgetAfter|nothing" />
 </div>

Added: z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py	                        (rev 0)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/browser/widget.py	2008-12-19 21:53:01 UTC (rev 94205)
@@ -0,0 +1,26 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+""" 
+
+$Id:  2007-12-12 12:27:02Z fafhrd $
+"""
+from zope import interface, component
+from z3c.form.interfaces import IWidget
+from z3ext.layout.interfaces import IPageletManager
+
+
+ at component.adapter(IWidget)
+ at interface.implementer(IPageletManager)
+def getWidgetManager(widget):
+    return widget.field, widget.form

Modified: z3ext.layoutform/trunk/src/z3ext/layoutform/form.py
===================================================================
--- z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	2008-12-19 21:50:58 UTC (rev 94204)
+++ z3ext.layoutform/trunk/src/z3ext/layoutform/form.py	2008-12-19 21:53:01 UTC (rev 94205)
@@ -137,7 +137,7 @@
         self.actions.execute()
 
 
-class PageletDisplayForm(form.DisplayForm, PageletForm):
+class PageletDisplayForm(PageletForm, form.DisplayForm):
     interface.implements(IPageletDisplayForm)
 
     render = PageletForm.render



More information about the Checkins mailing list