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, file_callback, field_callback]) |
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.
The optional argument file_callback allows the application to override both file creation/deletion semantics and location. See 4.6.2 ``FieldStorage Examples'' for additional information. New in version 3.2
The optional argument field_callback allows the application to override both the creation/deletion semantics and behaviour. New in version 3.2
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) |