Sophie

Sophie

distrib > Mandriva > 8.2 > i586 > media > contrib > by-pkgid > 12aef6395c3678c929b08cd723fc1673 > files > 89

mod_python-2.7.6-1mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.3.2.1 Request Methods</title>
<META NAME="description" CONTENT="4.3.2.1 Request Methods">
<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-mprequest-mem.html">
<LINK REL="previous" href="pyapi-mprequest.html">
<LINK REL="up" href="pyapi-mprequest.html">
<LINK REL="next" href="pyapi-mprequest-mem.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="pyapi-mprequest.html"><img src="icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-mprequest.html"><img src="icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-mprequest-mem.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-mprequest.html">4.3.2 Request Object&nbsp;</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-mprequest.html">4.3.2 Request Object&nbsp;</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mprequest-mem.html">4.3.2.2 Request Members</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->

<H3><A NAME="SECTION006321000000000000000">&nbsp;</A>
<BR>
4.3.2.1 Request Methods
</H3>

<P>
<dl><dt><b><a name='l2h-23'><tt class='method'>add_handler</tt></a></b>(<var>htype, handler</var><big>[</big><var>, dir</var><big>]</big>)
<dd>

<P>
Allows dynamic handler registration. <var>htype</var> is a string
containing the name of any of the apache <code>Python*Handler</code>
directives, e.g. "<tt class="samp">PythonHandler</tt>". <var>handler</var> is a string
containing the name of the module and the handler function.  Optional
<var>dir</var> is a string containing the name of the directory to be added
to the pythonpath. If no directory is specified, then, if there is
already a handler of the same type specified, its directory is
inherited, otherwise the directory of the presently executing handler
is used.

<P>
A handler added this way only persists throughout the life of the
request. It is possible to register more handlers while inside the
handler of the same type. One has to be careful as to not to create an
infinite loop this way.

<P>
Dynamic handler registration is a useful technique that allows the
code to dynamically decide what will happen next. A typical example
might be a <code>PythonAuthenHandler</code> that will assign different
<code>PythonHandlers</code> based on the authorization level, something like:

<P>
<dl><dd><pre class="verbatim">
if manager:
    req.add_handler("PythonHandler", "menu::admin")
else:
    req.add_handler("PythonHandler", "menu::basic")
</pre></dl>                              

<P>
Note: There is no checking being done on the validity of the handler
name. If you pass this function an invalid handler it will simply be
ignored.
</dl>

<P>
<dl><dt><b><a name='l2h-24'><tt class='method'>add_common_vars</tt></a></b>()
<dd>
Calls the Apache <tt class="cfunction">ap_add_common_vars()</tt> function. After a
call to this method, <tt class="member">Request.subprocess_env</tt> will contain a
lot of CGI information.
</dl>

<P>
<dl><dt><b><a name='l2h-25'><tt class='method'>child_terminate</tt></a></b>()
<dd>
Terminate a child process. This should terminate the current child
process in a nice fashion.

<P>
This method does nothing in multithreaded environments (e.g. Windows). 
</dl>

<P>
<dl><dt><b><a name='l2h-26'><tt class='method'>get_basic_auth_pw</tt></a></b>()
<dd>
Returns a string containing the password when Basic authentication is
used.
</dl>

<P>
<dl><dt><b><a name='l2h-27'><tt class='method'>get_config</tt></a></b>()
<dd>
Returns a reference to the table object containing the configuration
in effect for this request. The table has directives as keys, and
their values, if any, as values.
</dl>

<P>
<dl><dt><b><a name='l2h-28'><tt class='method'>get_dirs</tt></a></b>()
<dd>
Returns a reference to the table object keyed by directives currently
in effect and having directory names of where the particular directive
was last encountered as values. For every key in the table returned by
<tt class="method">get_config()</tt>, there will be a key in this table. If the directive was
in one of the server config files outside of any <code>&lt;Directory&gt;</code>,
then the value will be an empty string.
</dl>

<P>
<dl><dt><b><a name='l2h-29'><tt class='method'>get_remote_host</tt></a></b>(<var>type</var>)
<dd>

<P>
Returns the a string with the remote client's DNS name or IP or
<code>None</code> on failure. The first call to this function may entail a
DNS look up, but subsequent calls will use the cached result from the
first call.

<P>
The optional type argument can specify the following: 

<P>

<UL>
<LI><code>apache.REMOTE_HOST</code> Look up the DNS name. Fail if Apache 
directive <code>HostNameLookups</code> is <code>off</code> or the hostname cannot
be determined.

<P>
</LI>
<LI><code>apache.REMOTE_NAME</code> <i>(Default)</i> Return the DNS name if
possible, or the IP (as a string in dotted decimal notation)
otherwise.

<P>
</LI>
<LI><code>apache.REMOTE_NOLOOKUP</code> Don't perform a DNS lookup, return an
IP. Note: if a lookup was performed prior to this call, then the
cached host name is returned.

<P>
</LI>
<LI><code>apache.REMOTE_DOUBLE_REV</code> Force a double-reverse lookup. On 
failure, return None.

<P>
</LI>
</UL>

<P>
</dl>

<P>
<dl><dt><b><a name='l2h-30'><tt class='method'>get_options</tt></a></b>()
<dd>
Returns a reference to the table object containing the options set by
the <code>PythonOption</code> directives.
</dl>

<P>
<dl><dt><b><a name='l2h-31'><tt class='method'>read</tt></a></b>(<big>[</big><var>len</var><big>]</big>)
<dd>

<P>
Reads at most <var>len</var> bytes directly from the client, returning a
string with the data read. If the <var>len</var> argument is negative or
ommitted, reads all data given by the client.

<P>
This function is affected by the <code>Timeout</code> Apache configuration
directive. The read will be aborted and an <tt class="exception">IOError</tt> raised
if the <code>Timeout</code> is reached while reading client data.

<P>
This function relies on the client providing the <code>Content-length</code>
header. Absense of the <code>Content-length</code> header will be treated as
if <code>Content-length: 0</code> was supplied.

<P>
Incorrect <code>Content-length</code> may cause the function to try to read
more data than available, which will make the function block until a
<code>Timeout</code> is reached.

<P>
</dl>

<P>
<dl><dt><b><a name='l2h-32'><tt class='method'>readline</tt></a></b>(<big>[</big><var>len</var><big>]</big>)
<dd>
Like <tt class="function">read()</tt> but reads until end of line. 

<P>
Note that in accordance with the HTTP specification, most clients will
be terminating lines with "&#92;r&#92;n" rather
than simply "&#92;n".

<P>
</dl>

<P>
<dl><dt><b><a name='l2h-33'><tt class='method'>register_cleanup</tt></a></b>(<var>callable</var><big>[</big><var>, data</var><big>]</big>)
<dd>

<P>
Registers a cleanup. Argument <var>callable</var> can be any callable
object, the optional argument <var>data</var> can be any object (default is
<code>None</code>). At the very end of the request, just before the actual
request record is destroyed by Apache, <var>callable</var> will be called
with one argument, <var>data</var>.

<P>
</dl>

<P>
<dl><dt><b><a name='l2h-34'><tt class='method'>send_http_header</tt></a></b>()
<dd>
Starts the output from the request by sending the HTTP headers. This
function has no effect when called more than once within the same
request. Any manipulation of <tt class="member">Request.headers_out</tt> after this
function has been called is pointless since the headers have already
been sent to the client.
</dl>

<P>
<dl><dt><b><a name='l2h-35'><tt class='method'>write</tt></a></b>(<var>string</var>)
<dd>
Writes <var>string</var> directly to the client, then flushes the buffer. 
</dl>

<P>

<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="pyapi-mprequest.html"><img src="icons/previous.gif"
  border="0" height="32"
  alt="Previous Page" width="32"></A></td>
<td><A href="pyapi-mprequest.html"><img src="icons/up.gif"
  border="0" height="32"
  alt="Up One Level" width="32"></A></td>
<td><A href="pyapi-mprequest-mem.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-mprequest.html">4.3.2 Request Object&nbsp;</A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-mprequest.html">4.3.2 Request Object&nbsp;</A>
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-mprequest-mem.html">4.3.2.2 Request Members</A>
<hr>
<span class="release-info">Release 2.7.6, documentation updated on August 04, 2001.</span>
</DIV>
<!--End of Navigation Panel-->

</BODY>
</HTML>