home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
p
/
python
/
pyhtmldoc
/
f
/
functions
< prev
Wrap
Text File
|
1996-11-14
|
3KB
|
61 lines
<TITLE>Functions -- Python library reference</TITLE>
Next: <A HREF="../c/caring_about_security" TYPE="Next">Caring about security</A>
Prev: <A HREF="../o/old_classes" TYPE="Prev">Old classes</A>
Up: <A HREF="../c/cgi" TYPE="Up">cgi</A>
Top: <A HREF="../t/top" TYPE="Top">Top</A>
<H2>10.1.4. Functions</H2>
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.
<P>
<DL><DT><B>parse</B> (<VAR>fp</VAR>) -- function of module cgi<DD>
: Parse a query in the environment or from a file (default <CODE>sys.stdin</CODE>).
</DL>
<DL><DT><B>parse_qs</B> (<VAR>qs</VAR>) -- function of module cgi<DD>
: parse a query string given as a string argument (data of type
<CODE>application/x-www-form-urlencoded</CODE>).
</DL>
<DL><DT><B>parse_multipart</B> (<VAR>fp</VAR>, <VAR>pdict</VAR>) -- function of module cgi<DD>
: parse input of type <CODE>multipart/form-data</CODE> (for
file uploads). Arguments are <CODE>fp</CODE> for the input file and
<CODE>pdict</CODE> for the dictionary containing other parameters of <CODE>content-type</CODE> header
<P>
Returns a dictionary just like <CODE>parse_qs()</CODE>: 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 <CODE>FieldStorage</CODE> class instead which is much more flexible. Note
that <CODE>content-type</CODE> is the raw, unparsed contents of the <CODE>content-type</CODE>
header.
<P>
Note that this does not parse nested multipart parts -- use <CODE>FieldStorage</CODE> for
that.
</DL>
<DL><DT><B>parse_header</B> (<VAR>string</VAR>) -- function of module cgi<DD>
: parse a header like <CODE>Content-type</CODE> into a main
content-type and a dictionary of parameters.
</DL>
<DL><DT><B>test</B> () -- function of module cgi<DD>
: robust test CGI script, usable as main program.
Writes minimal HTTP headers and formats all information provided to
the script in HTML form.
</DL>
<DL><DT><B>print_environ</B> () -- function of module cgi<DD>
: format the shell environment in HTML.
</DL>
<DL><DT><B>print_form</B> (<VAR>form</VAR>) -- function of module cgi<DD>
: format a form in HTML.
</DL>
<DL><DT><B>print_directory</B> () -- function of module cgi<DD>
: format the current directory in HTML.
</DL>
<DL><DT><B>print_environ_usage</B> () -- function of module cgi<DD>
: print a list of useful (used by CGI) environment variables in
HTML.
</DL>
<DL><DT><B>escape</B> () -- function of module cgi<DD>
: convert the characters ``<CODE>&</CODE>'', ``<CODE><</CODE>'' and ``<CODE>></CODE>'' to HTML-safe
sequences. Use this if you need to display text that might contain
such characters in HTML. To translate URLs for inclusion in the HREF
attribute of an <CODE><A></CODE> tag, use <CODE>urllib.quote()</CODE>.
</DL>