Name

getvalue

Synopsis

                        f.getvalue(key,default=None)

Like f [ key ].value when f .has_key( key ), otherwise returns default. getvalue is slightly less convenient than methods getfirst or getlist; the only reason to use getvalue is if your script must remain compatible with old versions of Python, since methods getfirst and getlist were introduced in Python 2.2.

An instance f of class FieldStorage supplies the following attributes:

disposition

The Content-Disposition header, or None if no such header is present

disposition_options

A mapping of all the options in the Content-Disposition header, if any

headers

A mapping of all headers, normally an instance of the rfc822.Message class covered in Chapter 21

file

A file-like object from which you can read the control’s value, if applicable; None if the value is held in memory as a string, as happens for most controls

filename

The filename as specified by the client, for file controls; otherwise None

name

The name attribute of the control, or None if no such attribute is present

type

The Content-Type header, or None if no such header is present

type_options

A mapping of all the options in the Content-Type header, if any

value

The control’s value as a string; if f is keeping the control’s value in a file, then f implicitly reads the file into memory each time you access f .value

In most cases, attribute value is all you need. Other attributes are useful for file controls, which may have very large values and metadata such ...

Get Python in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.