ANN: ClientForm 0.0.11 and 0.1.5a released

http://wwwsearch.sourceforge.net/ClientForm/ A new stable and development release. Changes from 0.0.10 to 0.0.11: * Default selection for RADIO with no explictly selected items in HTML now correctly follows browser behaviour. This browser behaviour is in conflict with HTML 4.01. The various select_default arguments, as before, make everything follow HTML 4.01. * RadioControls now no longer have to have exactly one item selected: zero items can now be selected, in accordance with browser behaviour. Changes from 0.1.3a to 0.1.5a: This may be the last alpha release. A lot of interface changes. I don't recommend upgrading to 0.1.x from old 0.0.x code unless you want the new features. Everything is now much more consistent and, I hope, convenient. Also, direct use of Control objects should now be needed only rarely. Instead, just call methods on HTMLForm objects. Note that the web page above refers to the old interface. See here for the new one: http://wwwsearch.sourceforge.net/ClientForm/src/README-0_1_5a.html * Equivalent changes to those listed above for the stable release. * File upload now actually seems to work (replaced \n with \r\n). * Multiple file upload has been implemented (not yet tested on the web). * ListControls now always take sequence values, never string-like values or None. * Exceptions raised have now changed completely. * disabled attribute is now handled differently: if any item is disabled, the control's value can only be set directly if no attempt is made to select a disabled item (deselection is OK). The set and .toggle methods can still be used, but again, individual items can't be selected if they're disabled. There are several new methods to manipulate the disabled state of items. OPTGROUP is taken account of when parsing, to determine which items are disabled. * All controls now have the readonly attribute. * clear methods are gone, to be replaced by selected argument to set methods. * The HTMLForm.set and .toggle methods now take value as second and first arguments respectively, with the other arguments reflecting those of find_control (ie. name, type, kind, nr). * New argument to various HTMLForm methods: by_label. * Lots of new methods on HTMLForm. HTMLForm.find_control shouldn't be needed any more (rarely, anyway). All these methods take the same style of arguments as .set and .toggle. * New argument to HTMLForm.find_control: kind. Allows you to request controls that satisfy particular interfaces without specifying the exact type string. Values are "list", "singlelist", "multilist", "text", "file", "clickable". Also in HTMLForm methods, where appropriate. * New argument to HTMLForm.find_control: predicate. Not exposed in other HTMLForm methods. * Renamed HTMLForm.find_item --> get_item_attrs. * Renamed HTMLForm.click_items --> click_pairs. * Renamed items --> pairs everywhere. * Renamed get_value_as_label --> get_value_by_label. * Renamed possible_values --> possible_items. * Renamed possible_labels --> possible_item_labels. * Removed nr argument from all methods related to get_item_attrs. * SelectControl.set_by_label and .toggle_by_label have now gone, to be replaced by by_label arguments to .set and .toggle. * HTML attribute dictionaries now contain *all* original HTML attributes, including those that are exposed elsewhere in the ClientForm API (such as name, type, multiple, selected). * HTMLForm.set and .toggle methods have been extended to work with single-selection controls. * HTMLForm now has toggle_single and set_single methods. This is useful when you have a single-item list control (usually a single checkbox that you want to check), and you want to select that item without having to know what the item's name is (it's usually something meaningless like "1" or "on"). * Empty SelectControl can now be constructed. * Moved most documentation from Control objects into HTMLForm. The class docstring for HTMLForm now contains most of what you need to know. * Assorted code cleanup and minor bugfixes. Requires Python >= 1.5.2. 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. Simple example: from urllib2 import urlopen from ClientForm import ParseResponse forms = ParseResponse(urlopen("http://www.acme.com/form.html")) form = forms[0] print form form["author"] = "Gisle Aas" # form.click returns a urllib2.Request object # (see HTMLForm.click_request_data.__doc__ if you're not using urllib2) response = urlopen(form.click("Thanks")) John
participants (1)
-
jjl@pobox.com