1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
|
<!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">
<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-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 </A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-mprequest.html">4.3.2 Request Object </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"> </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><Directory></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 "\r\n" rather
than simply "\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 </A>
<b class="navlabel">Up:</b> <a class="sectref" href="pyapi-mprequest.html">4.3.2 Request Object </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.10, documentation updated on December 07, 2003.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
|