Access to form data is provided via the FieldStorage class. This class is similar to the standard library module cgi FieldStorage.
req[, keep_blank_values, strict_parsing]) |
The optional argument keep_blank_values is a flag indicating whether blank values in URL encoded form data should be treated as blank strings. The default is false, which means that blank values are ignored as if they were not included.
The optional argument strict_parsing is not yet implemented.
During initialization, FieldStorage class reads all of the data provided by the client. Since all data provided by the client is consumed at this point, there should be no more than one FieldStorage class instantiated per single request, nor should you make any attempts to read client data before or after instantiating a FieldStorage.
The data read from the client is then parsed into separate fields and
packaged in Field objects, one per field. For HTML form inputs
of type file
, a temporary file is created that can later be
accessed via the file attribute of a Field object.
The FieldStorage class has a mapping object interface, i.e. it can be treated like a dictionary. When used as a mapping, the keys are form input names, and the returned dictionary value can be:
<select>
HTML form
element.
In addition to standard mapping object methods, FieldStorage objects have the following attributes:
FieldStorage methods:
name[, default]) |
None
if not
specified.
name) |