[Checkins] SVN: z3c.form/trunk/src/z3c/form/ * Improved documentation in form.txt.

Roy Mathew roymath at yahoo.com
Tue Jul 24 18:52:38 EDT 2007


Log message for revision 78320:
  * Improved documentation in form.txt.
  
  * Refactored bool terms to have same token, even when term titles changes. This makes the API more stable.
  
  

Changed:
  U   z3c.form/trunk/src/z3c/form/browser/README.txt
  U   z3c.form/trunk/src/z3c/form/browser/checkbox.txt
  U   z3c.form/trunk/src/z3c/form/browser/radio.txt
  U   z3c.form/trunk/src/z3c/form/form.txt
  U   z3c.form/trunk/src/z3c/form/term.py

-=-
Modified: z3c.form/trunk/src/z3c/form/browser/README.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/README.txt	2007-07-24 21:15:17 UTC (rev 78319)
+++ z3c.form/trunk/src/z3c/form/browser/README.txt	2007-07-24 22:52:38 UTC (rev 78320)
@@ -76,13 +76,13 @@
   >>> print widget.render()
   <span class="option">
     <input type="radio" id="foo-0" name="bar:list"
-           class="radioWidget bool-field" value="yes" checked="checked" />
+           class="radioWidget bool-field" value="true" checked="checked" />
     <label for="foo-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="radio" id="foo-1" name="bar:list"
-           class="radioWidget bool-field" value="no" />
+           class="radioWidget bool-field" value="false" />
     <label for="foo-1">
       <span class="label">no</span>
     </label>
@@ -106,14 +106,14 @@
   >>> print widget.render()
   <span class="option">
     <input type="checkbox" id="foo-0" name="bar:list"
-           class="checkBoxWidget bool-field" value="yes"
+           class="checkBoxWidget bool-field" value="true"
            checked="checked" />
     <label for="foo-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="checkbox" id="foo-1" name="bar:list"
-           class="checkBoxWidget bool-field" value="no" />
+           class="checkBoxWidget bool-field" value="false" />
     <label for="foo-1">
       <span class="label">no</span>
     </label>

Modified: z3c.form/trunk/src/z3c/form/browser/checkbox.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/checkbox.txt	2007-07-24 21:15:17 UTC (rev 78319)
+++ z3c.form/trunk/src/z3c/form/browser/checkbox.txt	2007-07-24 22:52:38 UTC (rev 78320)
@@ -76,13 +76,13 @@
   >>> print widget.render()
   <span class="option">
     <input type="checkbox" id="widget-id-0" name="widget.name:list"
-           class="checkBoxWidget" value="yes" />
+           class="checkBoxWidget" value="true" />
     <label for="widget-id-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="checkbox" id="widget-id-1" name="widget.name:list"
-           class="checkBoxWidget" value="no" />
+           class="checkBoxWidget" value="false" />
     <label for="widget-id-1">
       <span class="label">no</span>
     </label>
@@ -92,19 +92,19 @@
 If we set the value for the widget to ``yes``, we can se that the checkbox
 field get rendered with a checked flag:
 
-  >>> widget.value = 'yes'
+  >>> widget.value = 'true'
   >>> widget.update()
   >>> print widget.render()
   <span class="option">
     <input type="checkbox" id="widget-id-0" name="widget.name:list"
-           class="checkBoxWidget" value="yes"
+           class="checkBoxWidget" value="true"
            checked="checked" />
     <label for="widget-id-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="checkbox" id="widget-id-1" name="widget.name:list"
-           class="checkBoxWidget" value="no" />
+           class="checkBoxWidget" value="false" />
     <label for="widget-id-1">
       <span class="label">no</span>
     </label>

Modified: z3c.form/trunk/src/z3c/form/browser/radio.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/browser/radio.txt	2007-07-24 21:15:17 UTC (rev 78319)
+++ z3c.form/trunk/src/z3c/form/browser/radio.txt	2007-07-24 22:52:38 UTC (rev 78320)
@@ -70,13 +70,13 @@
   >>> print widget.render()
   <span class="option">
     <input type="radio" id="widget-id-0" name="widget.name:list"
-           class="radioWidget" value="yes" />
+           class="radioWidget" value="true" />
     <label for="widget-id-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="radio" id="widget-id-1" name="widget.name:list"
-           class="radioWidget" value="no" />
+           class="radioWidget" value="false" />
     <label for="widget-id-1">
       <span class="label">no</span>
     </label>
@@ -86,18 +86,18 @@
 If we set the value for the widget to ``yes``, we can se that the radio field
 get rendered with a checked flag:
 
-  >>> widget.value = 'yes'
+  >>> widget.value = 'true'
   >>> widget.update()
   >>> print widget.render()
   <span class="option">
     <input type="radio" id="widget-id-0" name="widget.name:list"
-           class="radioWidget" value="yes" checked="checked" />
+           class="radioWidget" value="true" checked="checked" />
     <label for="widget-id-0">
       <span class="label">yes</span>
     </label>
   </span><span class="option">
     <input type="radio" id="widget-id-1" name="widget.name:list"
-           class="radioWidget" value="no" />
+           class="radioWidget" value="false" />
     <label for="widget-id-1">
       <span class="label">no</span>
     </label>

Modified: z3c.form/trunk/src/z3c/form/form.txt
===================================================================
--- z3c.form/trunk/src/z3c/form/form.txt	2007-07-24 21:15:17 UTC (rev 78319)
+++ z3c.form/trunk/src/z3c/form/form.txt	2007-07-24 22:52:38 UTC (rev 78320)
@@ -221,11 +221,12 @@
   'input'
 
 Deciding which mode to use, however, might not be a trivial operation. It
-might depend on several factors:
+might depend on several factors (items listed later override earlier ones):
 
+* The global ``mode`` flag of the widget manager
 * The permission to the content's data value
-* The manual ``mode`` flag in the field
 * The ``readonly`` flag in the schema field
+* The ``mode`` flag in the field
 
 
 Widget Attribute Values
@@ -330,6 +331,11 @@
 Submitting an add form successfully
 -----------------------------------
 
+Initially the root folder of the application is empty:
+
+  >>> sorted(root)
+  []
+
 Let's now fill the request with all the right values so that upon submitting
 the form with the "Add" button, the person should be added to the root folder:
 
@@ -377,8 +383,8 @@
 The widget manager and the widget causing the error should have an error
 message:
 
-  >>> [error for error in addForm.widgets.errors]
-  [<ErrorViewSnippet for RequiredMissing>]
+  >>> [(error.widget.__name__, error) for error in addForm.widgets.errors]
+  [('name', <ErrorViewSnippet for RequiredMissing>)]
 
   >>> addForm.widgets['name'].error
   <ErrorViewSnippet for RequiredMissing>
@@ -452,7 +458,7 @@
   [(u'Name', <ErrorViewSnippet for RequiredMissing>),
    (u'Age', <ErrorViewSnippet for TooSmall>)]
 
-But the errror message for a negative age is too generic:
+But the error message for a negative age is too generic:
 
   >>> print addForm.widgets['age'].error.render()
   <div class="error">Value is too small</div>
@@ -511,7 +517,7 @@
   'form'
 
 The template can then use those attributes, if it likes to. Since we are
-talking about templates, in this example we set the template manual, but if no
+talking about templates, in this example we set the template manually, but if no
 template is specified, the system tries to find an adapter. Initially, there
 is no adapter, so rendering the form fails:
 
@@ -534,7 +540,8 @@
   ...
   </html>
 
-Since a form can also be used as a page itself, it is callable:
+Since a form can also be used as a page itself, it is callable --
+invoking both the ``update()`` and ``render()`` methods:
 
   >>> print addForm()
   <html>

Modified: z3c.form/trunk/src/z3c/form/term.py
===================================================================
--- z3c.form/trunk/src/z3c/form/term.py	2007-07-24 21:15:17 UTC (rev 78319)
+++ z3c.form/trunk/src/z3c/form/term.py	2007-07-24 22:52:38 UTC (rev 78320)
@@ -88,8 +88,9 @@
         self.form = form
         self.field = field
         self.widget = widget
-        terms = [vocabulary.SimpleTerm(value, title, title=title)
-                 for title, value in [(self.trueLabel, True), (self.falseLabel, False)]]
+        terms = [vocabulary.SimpleTerm(*args)
+                 for args in [(True, 'true', self.trueLabel),
+                              (False, 'false', self.falseLabel)]]
         self.terms = vocabulary.SimpleVocabulary(terms)
 
 



More information about the Checkins mailing list