Sophie

Sophie

distrib > Mandriva > 9.2 > i586 > by-pkgid > dddfd1c874d00a6a720179bd81bafd8d > files > 118

apache2-mod_python-2.0.47_3.1.0a-2mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.6.1 FieldStorage class</title>
<META NAME="description" CONTENT="4.6.1 FieldStorage class">
<META NAME="keywords" CONTENT="modpython">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<link rel="STYLESHEET" href="modpython.css">
<link rel="first" href="modpython.html">
<link rel="contents" href="contents.html" title="Contents">
<link rel="index" href="genindex.html" title="Index">
<LINK REL="next" href="pyapi-util-fstor-fld.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.png"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-util.html"><img src="icons/up.png"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-util-fstor-fld.html"><img src="icons/next.png"
  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.png"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="icons/blank.png"
  border="0" height="32"
  alt="" width="32"></td>
<td><A href="genindex.html"><img src="icons/index.png"
  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.6 util - Miscellaneous</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-util.html">4.6 util - Miscellaneous</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-util-fstor-fld.html">4.6.2 Field class</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->

<H2><A NAME="SECTION006610000000000000000">&nbsp;</A>
<BR>
4.6.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>.

<P>
<dl><dt><b><span class="typelabel">class</span> <a name="l2h-167"><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 request 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.

<P>
During initialization, <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 single 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 mapping, the keys are
  form input names, and the returned dictionary value can be:

<P>

<UL>
<LI>An instance of <tt class="class">StringField</tt>, containing the form input
    value. This is only when there is a single value corresponding to the
    input name. <tt class="class">StringField</tt> is a subclass of <tt class="class">str</tt> which
    provides the additional <tt class="member">value</tt> attribute for compatibility
    with standard library <tt class="module">cgi</tt> module.
</LI>
<LI>An instances of a <tt class="class">Field</tt> class, if the input is a file upload.
</LI>
<LI>A list of <tt class="class">StringField</tt> 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>
<div class="note"><b class="label">Note:</b>
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. In all other cases an instance
    the return is an instance of <tt class="class">StringField</tt>, which is a subclass
    of <tt class="class">str</tt>. This means that you do not need to use the
    <tt class="member">.value</tt> attribute to access values of fields in most cases.
  </div>

<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-168"><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>
</dl>

<P>

<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.png"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-util.html"><img src="icons/up.png"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-util-fstor-fld.html"><img src="icons/next.png"
  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.png"
  border="0" height="32"
  alt="Contents" width="32"></A></td>
<td><img src="icons/blank.png"
  border="0" height="32"
  alt="" width="32"></td>
<td><A href="genindex.html"><img src="icons/index.png"
  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.6 util - Miscellaneous</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-util.html">4.6 util - Miscellaneous</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-util-fstor-fld.html">4.6.2 Field class</A>
<hr>
<span class="release-info">Release 3.1.0a, documentation updated on August 26, 2003.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>