Sophie

Sophie

distrib > PLD > ra > i686 > by-pkgid > 6000f42970817265a1498a30e9a2dba4 > files > 114

apache-mod_python-2.7.8-3.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.4.1 FieldStorage class</title>
<META NAME="description" CONTENT="4.4.1 FieldStorage class">
<META NAME="keywords" CONTENT="modpython">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="modpython.css">
<LINK REL="next" href="pyapi-util-funcs.html">
<LINK REL="previous" href="pyapi-util.html">
<LINK REL="up" href="pyapi-util.html">
<LINK REL="next" href="pyapi-util-fstor-fld.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="pyapi-util.html"><img src="icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-util.html"><img src="icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-util-fstor-fld.html"><img src="icons/next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td><A href="contents.html"><img src="icons/contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
<td><A href="genindex.html"><img src="icons/index.gif"
  border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-util.html">4.4 util - Miscellaneous</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-util.html">4.4 util - Miscellaneous</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-util-fstor-fld.html">4.4.1.1 Field class</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION006410000000000000000">&nbsp;</A>
<BR>
4.4.1 FieldStorage class
</H2>

<P>
Access to form data is provided via the <tt class="class">FieldStorage</tt>
class. This class is similar to the standard library module <tt class="module">cgi</tt>
<tt class="class">FieldStorage</tt> (but there are a few differences).

<P>
<dl><dt><b>class <a name='l2h-121'><tt class='class'>FieldStorage</tt></a></b>(<var>req</var><big>[</big><var>, keep_blank_values, strict_parsing</var><big>]</big>)
<dd>
This class provides uniform access to HTML form data submitted by the client.
<var>req</var> is an instance of the mod_python <tt class="class">Request</tt> object.

<P>
The optional argument <var>keep_blank_values</var> 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.

<P>
The optional argument <var>strict_parsing</var> is not yet implemented.
</dl>

<P>
While being instantiated, the <tt class="class">FieldStorage</tt> 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
<tt class="class">FieldStorage</tt> class instantiated per signle request, nor should
you make any attempts to read client data before or after
instantiating a <tt class="class">FieldStorage</tt>.

<P>
The data read from the client is then parsed into separate fields
and packaged in <tt class="class">Field</tt> objects, one per field. For HTML form
inputs of type <code>file</code>, a temporary file is created that can later be 
accessed via the <tt class="member">file</tt> attribute of a <tt class="class">Field</tt> object.

<P>
The <tt class="class">FieldStorage</tt> class has a mapping object interface, i.e. it
can be treated like a dictionary. When used as a dictionary, the dictionary 
keys are form input names, and the returned dictionary value can be:

<P>

<UL>
<LI>A string, containing the form input value. This is only when there is a single
value corresponding to the input name.
</LI>
<LI>An instances of a <tt class="class">Field</tt> class, if the input is a file upload.
</LI>
<LI>A list of strings and/or <tt class="class">Field</tt> objects. This is when multiple values
exist, such as for a <code>&lt;select&gt;</code> HTML form element.
</LI>
</UL>

<P>
Note that unlike the standard library <tt class="module">cgi</tt> module
<tt class="class">FieldStorage</tt> class, a
<tt class="class">Field</tt> object is returned <i>only</i> when it is a file
upload. This means that you do not need to use the <tt class="member">.value</tt>
attribute to access values of fields in most cases.

<P>
In addition to standard mapping object methods, <tt class="class">FieldStorage</tt> objects
have the following attributes:

<P>
<dl><dt><b><a name='l2h-122'><tt class='member'>list</tt></a></b>
<dd>
This is a list of <tt class="class">Field</tt> objects, one for each input. Multiple
inputs with the same name will have multiple elements in this list.
</dl>

<P>

<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL CLASS="ChildLinks">
<LI><A NAME="tex2html640"
  href="pyapi-util-fstor-fld.html">4.4.1.1 Field class</A>
</UL>
<!--End of Table of Child-Links-->

<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="pyapi-util.html"><img src="icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-util.html"><img src="icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-util-fstor-fld.html"><img src="icons/next.gif"
  border="0" height="32"
  alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Mod_python Manual</td>
<td><A href="contents.html"><img src="icons/contents.gif"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="icons/blank.gif"
  border="0" height="32"
  alt="" width="32"></td>
<td><A href="genindex.html"><img src="icons/index.gif"
  border="0" height="32"
  alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-util.html">4.4 util - Miscellaneous</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-util.html">4.4 util - Miscellaneous</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-util-fstor-fld.html">4.4.1.1 Field class</A>
<hr>
<span class="release-info">Release 2.7.8, documentation updated on April 19, 2002.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>