<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>4.5.2 Table Object (mp_table) </title> <META NAME="description" CONTENT="4.5.2 Table Object (mp_table) "> <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-mprequest.html"> <LINK REL="previous" href="pyapi-apmeth.html"> <LINK REL="up" href="module-apache.html"> <LINK REL="next" href="pyapi-mprequest.html"> </head> <body> <DIV CLASS="navigation"> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="pyapi-apmeth.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="pyapi-mprequest.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-apmeth.html">4.5.1 Functions</A> <b class="navlabel">Up:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mprequest.html">4.5.3 Request Object </A> <br><hr> </DIV> <!--End of Navigation Panel--> <H2><A NAME="SECTION006520000000000000000"> </A> <BR> 4.5.2 Table Object (mp_table)<a name="l2h-26"> </a> </H2> <P> <a name="l2h-29"> </a><dl><dt><b><span class="typelabel">class</span> <a name="l2h-27"><tt class="class">table</tt></a></b>(<big>[</big><var>mapping-or-sequence</var><big>]</big>) <dd> Returns a new empty object of type <code>mp_table</code>. See Section <A HREF="#pyapi-mptable">4.5.2</A> for description of the table object. The <var>mapping-or-sequence</var> will be used to provide initial values for the table. <P> The table object is a wrapper around the Apache APR table. The table object behaves very much like a dictionary (including the Python 2.2 features such as support of the <code>in</code> operator, etc.), with the following differences: <P> <UL> <LI>Both keys and values must be strings. </LI> <LI>Key lookups are case-insensitive. </LI> <LI>Duplicate keys are allowed (see <tt class="method">add()</tt> below). When there is more than one value for a key, a subscript operation returns a list. </LI> </UL> <P> Much of the information that Apache uses is stored in tables. For example, <tt class="member">req.headers_in</tt> and <tt class="member">req.headers_out</tt>. <P> All the tables that mod_python provides inside the request object are actual mappings to the Apache structures, so changing the Python table also changes the underlying Apache table. <P> In addition to normal dictionary-like behavior, the table object also has the following method: <P> <dl><dt><b><a name="l2h-28"><tt class="method">add</tt></a></b>(<var>key, val</var>) <dd> <tt class="function">add()</tt> allows for creating duplicate keys, which is useful when multiple headers, such as <code>Set-Cookie:</code> are required. </dl> <P> <span class="versionnote">New in version 3.0.</span> </dl> <P> <DIV CLASS="navigation"> <p><hr> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><A href="pyapi-apmeth.html"><img src="icons/previous.png" border="0" height="32" alt="Previous Page" width="32"></A></td> <td><A href="module-apache.html"><img src="icons/up.png" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A href="pyapi-mprequest.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-apmeth.html">4.5.1 Functions</A> <b class="navlabel">Up:</b> <a class="sectref" href="module-apache.html">4.5 apache - Access</A> <b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mprequest.html">4.5.3 Request Object </A> <hr> <span class="release-info">Release 3.1.0a, documentation updated on August 26, 2003.</span> </DIV> <!--End of Navigation Panel--> </BODY> </HTML>