RELEASE: ClientForm 0.0.4b

John J Lee
19 Nov 2002 11:12:39 -0800

ClientForm 0.0.4b

This is a beta release (probably the last before first stable release).

Changes since the last release (0.0.3b):

 * Changed license to MIT (from Perl Artistic).  Thanks, Gisle.
   [MIT license essentially says: don't sue me.]
 * Various bug-fixes and documentation improvements.
 * Internal changes (internal unless you're using your own form parser):
   Control, ListControl and ScalarControl constructor cleanup, and
   separation of ListControl into RadioControl, CheckboxControl and
 * Rather than using the values of the OPTION elements to set SELECT
   values, SELECT items can also be specified by the labels of the
   OPTION elements.  For example, if you have a SELECT control like so:

   <SELECT name="cheeses">
     <OPTION value="br">Brie</OPTION>
     <OPTION value="ched">Cheddar</OPTION>
     <OPTION value="grgnz" label="Gorgonzola">Special offer on

   instead of setting its value like this:

   form["cheeses"] = ["br", "ched", "grgnz"]

   you can now optionally use the more readable (and, possibly, more

   control = form.find_control("cheeses")
   control.set_value_by_label(["Brie", "Cheddar", "Gorgonzola"])

   Note that the label HTML attribute defaults to the content of the
   OPTION element (as does the value HTML attribute).

ClientForm is a Python module for handling HTML forms on the client
side, useful for parsing HTML forms, filling them in and returning the
completed forms to the server.  It has developed from a port of Gisle
Aas' Perl module HTML::Form, from the libwww-perl library, but the
interface is not the same.

 import ClientForm
 import urllib2
 request = urllib2.Request("")
 response = urllib2.urlopen(request)
 forms = ClientForm.ParseResponse(response)
 form = forms[0]
 form["cheeses"] = ["parmesan", "leicester", "cheddar"]
 form.toggle("cheeses", "gorgonzola")
 form["author"] = "Gisle Aas"
 request2 ="Thanks")
 response2 = urllib2.urlopen(request2)

 print response2.geturl()
 print  # headers
 for line in response2.readlines():  # body
     print line

All of the standard input types are supported: TEXT, PASSWORD, HIDDEN,
SELECT/OPTION.  FILE (for file upload) is not yet supported, but will
be in a future version.

Python 1.5.2 or above is required.  To run the tests, you need the
unittest module (from PyUnit).  unittest is a standard library module
with Python 2.1 and above.