11.2.4 Functions
Python Library Reference
Previous: 11.2.3 Old classes
Up: 11.2 cgi
Next: 11.2.5 Caring about security
11.2.4 Functions
These are useful if you want more control, or if you want to employ
some of the algorithms implemented in this module in other
circumstances.
parse (fp)
Parse a query in the environment or from a file (default
sys.stdin).
parse_qs (qs[, keep_blank_values, strict_parsing])
Parse a query string given as a string argument (data of type
application/x-www-form-urlencoded). Data are
returned as a dictionary. The dictionary keys are the unique query
variable names and the values are lists of values for each name.
The optional argument keep_blank_values is
a flag indicating whether blank values in
URL encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as
blank strings. The default false value indicates that
blank values are to be ignored and treated as if they were
not included.
The optional argument strict_parsing is a flag indicating what
to do with parsing errors. If false (the default), errors
are silently ignored. If true, errors raise a ValueError
exception.
parse_qsl (qs[, keep_blank_values, strict_parsing])
Parse a query string given as a string argument (data of type
application/x-www-form-urlencoded). Data are
returned as a list of name, value pairs.
The optional argument keep_blank_values is
a flag indicating whether blank values in
URL encoded queries should be treated as blank strings.
A true value indicates that blanks should be retained as
blank strings. The default false value indicates that
blank values are to be ignored and treated as if they were
not included.
The optional argument strict_parsing is a flag indicating what
to do with parsing errors. If false (the default), errors
are silently ignored. If true, errors raise a ValueError
exception.
parse_multipart (fp, pdict)
Parse input of type multipart/form-data (for
file uploads). Arguments are fp for the input file and
pdict for a dictionary containing other parameters in
the Content-Type header.
Returns a dictionary just like parse_qs() keys are the
field names, each value is a list of values for that field. This is
easy to use but not much good if you are expecting megabytes to be
uploaded -- in that case, use the FieldStorage class instead
which is much more flexible.
Note that this does not parse nested multipart parts -- use
FieldStorage for that.
parse_header (string)
Parse a MIME header (such as Content-Type) into a main
value and a dictionary of parameters.
test ()
Robust test CGI script, usable as main program.
Writes minimal HTTP headers and formats all information provided to
the script in HTML form.
print_environ ()
Format the shell environment in HTML.
print_form (form)
Format a form in HTML.
print_directory ()
Format the current directory in HTML.
print_environ_usage ()
Print a list of useful (used by CGI) environment variables in
HTML.
escape (s[, quote])
Convert the characters
"&", "<" and ">" in string s to
HTML-safe sequences. Use this if you need to display text that might
contain such characters in HTML. If the optional flag quote is
true, the double quote character (""") is also translated;
this helps for inclusion in an HTML attribute value, e.g. in <A
HREF="...">.
Python Library Reference
Previous: 11.2.3 Old classes
Up: 11.2 cgi
Next: 11.2.5 Caring about security
See About this document... for information on suggesting changes.
Wyszukiwarka
Podobne podstrony:
function in arrayfunction in arrayLinda R Waugh The Poetic Function in the Theory of Roman JakobsonUsing the cgi moduleFunctional Origins of Religious Concepts Ontological and Strategic Selection in Evolved Mindsfunction mcrypt module get algo key sizemodule cgiASP NET Module 5 Using Trace in Microsoft ASP NET Pagesfunction mcrypt module is block algorithm modewięcej podobnych podstron