[Zope-CVS] SVN: zope.webdev/trunk/ Setup the layer field on a page definition to use multi checkbox widget.

Rocky Burt rocky at serverzen.com
Tue Jan 31 13:00:29 EST 2006


Log message for revision 41516:
  Setup the layer field on a page definition to use multi checkbox widget.
  

Changed:
  _U  zope.webdev/trunk/
  U   zope.webdev/trunk/browser/base.py
  U   zope.webdev/trunk/browser/page.py
  U   zope.webdev/trunk/browser/page.txt

-=-

Property changes on: zope.webdev/trunk
___________________________________________________________________
Name: svk:merge
   + 98c0701e-2f07-0410-a1a0-c1bc72243522:/local/zope.webdev/trunk:7361

Modified: zope.webdev/trunk/browser/base.py
===================================================================
--- zope.webdev/trunk/browser/base.py	2006-01-31 17:47:30 UTC (rev 41515)
+++ zope.webdev/trunk/browser/base.py	2006-01-31 18:00:29 UTC (rev 41516)
@@ -61,6 +61,8 @@
 class EditFormBase(form.EditForm):
     '''A base class for display forms that are also edit forms.'''
 
+    form_edit_widgets = None
+
     def fixUpWidgets(self):
         pass
 
@@ -68,6 +70,9 @@
         for_display = True
         if 'doEdit' in self.request:
             for_display = False
+            if self.form_edit_widgets:
+                for key, value in self.form_edit_widgets.items():
+                    self.form_fields[key].custom_widget = value
 
         self.adapters = {}
         self.widgets = form.setUpEditWidgets(

Modified: zope.webdev/trunk/browser/page.py
===================================================================
--- zope.webdev/trunk/browser/page.py	2006-01-31 17:47:30 UTC (rev 41515)
+++ zope.webdev/trunk/browser/page.py	2006-01-31 18:00:29 UTC (rev 41516)
@@ -31,6 +31,8 @@
 from zope.security.proxy import removeSecurityProxy
 from zope.app.pagetemplate import ViewPageTemplateFile
 from zope.interface.common import idatetime
+from zope.app.form import CustomWidgetFactory
+from zope.app.form.browser import MultiCheckBoxWidget
 
 
 class AddForm(base.UtilityAddFormBase):
@@ -81,5 +83,5 @@
     form_fields = form.Fields(interfaces.IPage).select(
         'name', 'for_', 'layer', 'permission','templateSource',
         'moduleSource','className')
+    form_edit_widgets = {'layer': CustomWidgetFactory(MultiCheckBoxWidget)}
     template = ViewPageTemplateFile('package_overview.pt')
-

Modified: zope.webdev/trunk/browser/page.txt
===================================================================
--- zope.webdev/trunk/browser/page.txt	2006-01-31 17:47:30 UTC (rev 41515)
+++ zope.webdev/trunk/browser/page.txt	2006-01-31 18:00:29 UTC (rev 41516)
@@ -59,6 +59,42 @@
   >>> browser.open('http://localhost/++skin++WebDev/++etc++site/first')
   >>> browser.getLink('mypage.html').click()
 
+Go to the edit form.
+
   >>> browser.getControl('Edit').click()
   
+Edit the important values of the actual page such as the template source, etc
+and save them.
+
+  >>> browser.getControl('Template Source').value = u'''
+  ... <html><body>
+  ... <ul>
+  ...  <li tal:repeat="candy view/candies"
+  ...      tal:content="candy"/>
+  ... </ul>
+  ... </body></html>'''
+  >>> browser.getControl('Module Source').value = u'''
+  ... class CandyCollector(object):
+  ...     @property
+  ...     def candies(self):
+  ...         return ('blue', 'green', 'red')'''
+  >>> browser.getControl('Class Name').value = u'CandyCollector'
+  >>> browser.getControl('Apply').click()
+  
+Since we have created the new page and registered it, it is automatically
+setup as a registered view (we haven't explicitly done this).
+
+Now we will test the actual output of a use of the page/view from the root
+folder.
+
+  >>> browser.open('http://localhost/++skin++WebDev/@@mypage.html')
+  >>> print browser.contents
+  <html><body>
+  <ul>
+   <li>blue</li>
+   <li>green</li>
+   <li>red</li>
+  </ul>
+  </body></html>
+  
   
\ No newline at end of file



More information about the Zope-CVS mailing list