[wwwsearch-commits] r19535 - wwwsearch/ClientForm/trunk

jjlee at codespeak.net jjlee at codespeak.net
Sat Nov 5 02:05:50 CET 2005


Author: jjlee
Date: Sat Nov  5 02:05:49 2005
New Revision: 19535

Modified:
   wwwsearch/ClientForm/trunk/ClientForm.py
Log:
Doc tweaks

Modified: wwwsearch/ClientForm/trunk/ClientForm.py
==============================================================================
--- wwwsearch/ClientForm/trunk/ClientForm.py	(original)
+++ wwwsearch/ClientForm/trunk/ClientForm.py	Sat Nov  5 02:05:49 2005
@@ -64,7 +64,6 @@
 #    contents.  Or choice between matching labels exactly or by
 #    substring.  Etc.
 #   Remove deprecated methods.
-#   action should probably be an absolute URI, like DOMForm.
 #   ...what else?
 # Work on DOMForm.
 # XForms?  Don't know if there's a need here.
@@ -930,7 +929,7 @@
         self._text = attrs.get("__text").strip()
         self._ctext = compress_text(self._text)
         self.attrs = attrs
-        self._backwards_compat = False  # maintaned by HTMLForm
+        self._backwards_compat = False  # maintained by HTMLForm
 
     def __getattr__(self, name):
         if name == "text":
@@ -950,7 +949,7 @@
         return '<Label(id=%r, text=%r)>' % (self.id, self.text)
 
 
-def _getLabel(attrs):
+def _get_label(attrs):
     text = attrs.get("__label")
     if text is not None:
         return Label(text)
@@ -1093,7 +1092,7 @@
     """
     def __init__(self, type, name, attrs, index=None):
         self._index = index
-        self._label = _getLabel(attrs)
+        self._label = _get_label(attrs)
         self.__dict__["type"] = type.lower()
         self.__dict__["name"] = name
         self._value = attrs.get("value")
@@ -1161,7 +1160,6 @@
 
     INPUT/TEXT
     INPUT/PASSWORD
-    INPUT/FILE
     INPUT/HIDDEN
     TEXTAREA
 
@@ -1381,7 +1379,7 @@
 
 class Item:
     def __init__(self, control, attrs, index=None):
-        label = _getLabel(attrs)
+        label = _get_label(attrs)
         self.__dict__.update({
             "name": attrs["value"],
             "_labels": label and [label] or [],
@@ -1793,7 +1791,7 @@
 
     def merge_control(self, control):
         assert bool(control.multiple) == bool(self.multiple)
-        #assert isinstance(control, self.__class__)
+        # usually, isinstance(control, self.__class__)
         self.items.extend(control.items)
 
     def fixup(self):
@@ -2084,6 +2082,9 @@
 
     SELECT (and OPTION)
 
+
+    OPTION 'values', in HTML parlance, are Item 'names' in ClientForm parlance.
+
     SELECT control values and labels are subject to some messy defaulting
     rules.  For example, if the HTML representation of the control is:
 
@@ -2094,9 +2095,9 @@
     </SELECT>
 
     The items, in order, have labels "2002", "2001" and "2000", whereas their
-    values are "0", "1" and "2000" respectively.  Note that the value of the
-    last OPTION in this example defaults to its contents, as specified by RFC
-    1866, as do the labels of the second and third OPTIONs.
+    names (the OPTION values) are "0", "1" and "2000" respectively.  Note that
+    the value of the last OPTION in this example defaults to its contents, as
+    specified by RFC 1866, as do the labels of the second and third OPTIONs.
 
     The OPTION labels are sometimes more meaningful than the OPTION values,
     which can make for more maintainable code.
@@ -2106,14 +2107,13 @@
     The attrs attribute is a dictionary of the original HTML attributes of the
     SELECT element.  Other ListControls do not have this attribute, because in
     other cases the control as a whole does not correspond to any single HTML
-    element.  The get_item_attrs method may be used as usual to get at the
-    HTML attributes of the HTML elements corresponding to individual list items
-    (for SELECT controls, these are OPTION elements).
-
-    Another special case is that the attributes dictionaries returned by
-    get_item_attrs have a special key "contents" which does not correspond to
-    any real HTML attribute, but rather contains the contents of the OPTION
-    element:
+    element.  control.get(...).attrs may be used as usual to get at the HTML
+    attributes of the HTML elements corresponding to individual list items (for
+    SELECT controls, these are OPTION elements).
+
+    Another special case is that the Item.attrs dictionaries have a special key
+    "contents" which does not correspond to any real HTML attribute, but rather
+    contains the contents of the OPTION element:
 
     <OPTION>this bit</OPTION>
 
@@ -2136,7 +2136,7 @@
         # fish out the SELECT HTML attributes from the OPTION HTML attributes
         # dictionary
         self.attrs = attrs["__select"].copy()
-        self.__dict__["_label"] = _getLabel(self.attrs)
+        self.__dict__["_label"] = _get_label(self.attrs)
         self.__dict__["id"] = self.attrs.get("id")
         self.__dict__["multiple"] = self.attrs.has_key("multiple")
         # the majority of the contents, label, and value dance already happened
@@ -2169,8 +2169,8 @@
     def fixup(self):
         ListControl.fixup(self)
         # Firefox doesn't exclude disabled items from those considered here
-        # (i.e. from 'found', for both brances of the if below).  Note that IE
-        # doesn't support the disabled attribute on OPTIONs at all.
+        # (i.e. from 'found', for both branches of the if below).  Note that
+        # IE6 doesn't support the disabled attribute on OPTIONs at all.
         found = [o for o in self.items if o.selected]
         if not found:
             if not self.multiple or self._select_default:
@@ -2301,8 +2301,10 @@
     need to be more specific than just supplying the control's name, use the
     set_value and get_value methods.
 
-    ListControl values are lists of item names.  The list item's name is the
-    value of the corresponding HTML element's "value" attribute.
+    ListControl values are lists of item names (specifically, the names of the
+    items that are selected and not disabled, and hence are "successful" -- ie.
+    cause data to be returned to the server).  The list item's name is the
+    value of the corresponding HTML element's"value" attribute.
 
     Example:
 
@@ -2321,11 +2323,12 @@
 
     defines a SELECT control with name "more_cheeses" which has two items,
     named "1" and "2" (because the OPTION element's value HTML attribute
-    defaults to the element contents).
+    defaults to the element contents -- see SelectControl.__doc__ for more on
+    these defaulting rules).
 
     To select, deselect or otherwise manipulate individual list items, use the
     HTMLForm.find_control() and ListControl.get() methods.  To set the whole
-    value, do as for any other control:use indexing or the set_/get_value
+    value, do as for any other control: use indexing or the set_/get_value
     methods.
 
     Example:


More information about the wwwsearch-commits mailing list