~ubuntu-branches/ubuntu/karmic/libapache2-mod-python/karmic-updates

« back to all changes in this revision

Viewing changes to doc-html/pyapi-handler.html

  • Committer: Bazaar Package Importer
  • Author(s): Piotr Ozarowski
  • Date: 2007-02-21 18:24:29 UTC
  • mfrom: (1.1.8 feisty)
  • Revision ID: james.westby@ubuntu.com-20070221182429-9okop7e0qpi24l85
Tags: 3.2.10-4
* Added XS-Vcs-Svn field
* Removed "db_purge" part from libapache2-mod-python.postrm
  (dh_installdebconf is generating a rule that will not fail if debconf is
  already removed)
* Added initial Spanish debconf translation from Manuel Porras Peralta.
  (closes: #411235)
* Added initial Portuguese debconf translation from Pedro Ribeiro.
  (closes: #411742)
* Added initial Galician debconf translation from Jacobo Tarrio.
  (closes: #411831)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2
2
<html>
3
3
<head>
4
 
<title>4.2 Overview of a Request Handler</title>
5
 
<META NAME="description" CONTENT="4.2 Overview of a Request Handler">
 
4
<link rel="STYLESHEET" href="modpython.css" type='text/css'>
 
5
<link rel="first" href="modpython.html" title='Mod_python Manual'>
 
6
<link rel='contents' href='contents.html' title="Contents">
 
7
<link rel='index' href='genindex.html' title='Index'>
 
8
<link rel='last' href='about.html' title='About this document...'>
 
9
<link rel='help' href='about.html' title='About this document...'>
 
10
<LINK REL="next" href="pyapi-filter.html">
 
11
<LINK REL="prev" href="pyapi-interps.html">
 
12
<LINK REL="parent" href="pythonapi.html">
 
13
<LINK REL="next" href="pyapi-filter.html">
 
14
<meta name='aesop' content='information'>
 
15
<META NAME="description" CONTENT="Overview of a Request Handler">
6
16
<META NAME="keywords" CONTENT="modpython">
7
17
<META NAME="resource-type" CONTENT="document">
8
18
<META NAME="distribution" CONTENT="global">
9
 
<link rel="STYLESHEET" href="modpython.css">
10
 
<link rel="first" href="modpython.html">
11
 
<link rel="contents" href="contents.html" title="Contents">
12
 
<link rel="index" href="genindex.html" title="Index">
13
 
<LINK REL="next" href="pyapi-filter.html">
14
 
<LINK REL="previous" href="pyapi-interps.html">
15
 
<LINK REL="up" href="pythonapi.html">
16
 
<LINK REL="next" href="pyapi-filter.html">
 
19
<title>4.2 Overview of a Request Handler</title>
17
20
</head>
18
21
<body>
19
22
<DIV CLASS="navigation">
20
23
<table align="center" width="100%" cellpadding="0" cellspacing="2">
21
24
<tr>
22
 
<td><A href="pyapi-interps.html"><img src="icons/previous.gif"
23
 
  border="0" height="32"
24
 
  alt="Previous Page" width="32"></A></td>
25
 
<td><A href="pythonapi.html"><img src="icons/up.gif"
26
 
  border="0" height="32"
27
 
  alt="Up One Level" width="32"></A></td>
28
 
<td><A href="pyapi-filter.html"><img src="icons/next.gif"
29
 
  border="0" height="32"
30
 
  alt="Next Page" width="32"></A></td>
 
25
<td><a rel="prev" title="4.1 Multiple Interpreters" 
 
26
  href="pyapi-interps.html"><img src='previous.gif'
 
27
  border='0' height='32'  alt='Previous Page' width='32'></A></td>
 
28
<td><a rel="parent" title="4. Python API" 
 
29
  href="pythonapi.html"><img src='up.gif'
 
30
  border='0' height='32'  alt='Up One Level' width='32'></A></td>
 
31
<td><a rel="next" title="4.3 Overview of a" 
 
32
  href="pyapi-filter.html"><img src='next.gif'
 
33
  border='0' height='32'  alt='Next Page' width='32'></A></td>
31
34
<td align="center" width="100%">Mod_python Manual</td>
32
 
<td><A href="contents.html"><img src="icons/contents.gif"
33
 
  border="0" height="32"
34
 
  alt="Contents" width="32"></A></td>
35
 
<td><img src="icons/blank.gif"
36
 
  border="0" height="32"
37
 
  alt="" width="32"></td>
38
 
<td><A href="genindex.html"><img src="icons/index.gif"
39
 
  border="0" height="32"
40
 
  alt="Index" width="32"></A></td>
 
35
<td><a rel="contents" title="Table of Contents" 
 
36
  href="contents.html"><img src='contents.gif'
 
37
  border='0' height='32'  alt='Contents' width='32'></A></td>
 
38
<td><img src='blank.gif'
 
39
  border='0' height='32'  alt='' width='32'></td>
 
40
<td><a rel="index" title="Index" 
 
41
  href="genindex.html"><img src='index.gif'
 
42
  border='0' height='32'  alt='Index' width='32'></A></td>
41
43
</tr></table>
42
 
<b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-interps.html">4.1 Multiple Interpreters</A>
43
 
<b class="navlabel">Up:</b> <a class="sectref" href="pythonapi.html">4. Python API</A>
44
 
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-filter.html">4.3 Overview of a</A>
 
44
<b class="navlabel">Previous:</b>
 
45
<a class="sectref" rel="prev" href="pyapi-interps.html">4.1 Multiple Interpreters</A>
 
46
<b class="navlabel">Up:</b>
 
47
<a class="sectref" rel="parent" href="pythonapi.html">4. Python API</A>
 
48
<b class="navlabel">Next:</b>
 
49
<a class="sectref" rel="next" href="pyapi-filter.html">4.3 Overview of a</A>
45
50
<br><hr>
46
51
</DIV>
47
52
<!--End of Navigation Panel-->
50
55
<BR>
51
56
4.2 Overview of a Request Handler
52
57
</H1>
53
 
<a name="l2h-13">&nbsp;</a>
 
58
<a name="l2h-24">&nbsp;</a>
54
59
<P>
55
60
A <i class="dfn">handler</i> is a function that processes a particular phase of a
56
61
request. Apache processes requests in phases - read the request,
61
66
different from a handler written in C, and follows these rules:
62
67
 
63
68
<P>
64
 
<a name="l2h-14">&nbsp;</a>A handler function will always
 
69
<a name="l2h-26">&nbsp;</a> <a name="l2h-25">&nbsp;</a> A handler function will always
65
70
be passed a reference to a request object. (Throughout this manual,
66
71
the request object is often referred to by the <code>req</code> variable.)
67
72
 
86
91
  <var>HTTP_ERROR</var> can be any of the following:
87
92
 
88
93
<P>
89
 
<dl><dd><pre class="verbatim">
 
94
<div class="verbatim"><pre>
90
95
    HTTP_CONTINUE                     = 100
91
96
    HTTP_SWITCHING_PROTOCOLS          = 101
92
97
    HTTP_PROCESSING                   = 102
135
140
    HTTP_VARIANT_ALSO_VARIES          = 506
136
141
    HTTP_INSUFFICIENT_STORAGE         = 507
137
142
    HTTP_NOT_EXTENDED                 = 510
138
 
</pre></dl>                      
 
143
</pre></div>                      
139
144
 
140
145
<P>
141
146
</LI>
148
153
e.g.
149
154
 
150
155
<P>
151
 
<dl><dd><pre class="verbatim">
 
156
<div class="verbatim"><pre>
152
157
raise apache.SERVER_RETURN, apache.HTTP_FORBIDDEN
153
 
</pre></dl>
 
158
</pre></div>
154
159
 
155
160
<P>
156
161
Handlers can send content to the client using the <tt class="method">req.write()</tt>
172
177
An example of a minimalistic handler might be: 
173
178
 
174
179
<P>
175
 
<dl><dd><pre class="verbatim">
 
180
<div class="verbatim"><pre>
176
181
from mod_python import apache
177
182
 
178
183
def requesthandler(req):
179
184
    req.content_type = "text/plain"
180
185
    req.write("Hello World!")
181
186
    return apache.OK
182
 
</pre></dl>
 
187
</pre></div>
183
188
 
184
189
<P>
185
190
 
187
192
<p><hr>
188
193
<table align="center" width="100%" cellpadding="0" cellspacing="2">
189
194
<tr>
190
 
<td><A href="pyapi-interps.html"><img src="icons/previous.gif"
191
 
  border="0" height="32"
192
 
  alt="Previous Page" width="32"></A></td>
193
 
<td><A href="pythonapi.html"><img src="icons/up.gif"
194
 
  border="0" height="32"
195
 
  alt="Up One Level" width="32"></A></td>
196
 
<td><A href="pyapi-filter.html"><img src="icons/next.gif"
197
 
  border="0" height="32"
198
 
  alt="Next Page" width="32"></A></td>
 
195
<td><a rel="prev" title="4.1 Multiple Interpreters" 
 
196
  rel="prev" title="4.1 Multiple Interpreters" 
 
197
  href="pyapi-interps.html"><img src='previous.gif'
 
198
  border='0' height='32'  alt='Previous Page' width='32'></A></td>
 
199
<td><a rel="parent" title="4. Python API" 
 
200
  rel="parent" title="4. Python API" 
 
201
  href="pythonapi.html"><img src='up.gif'
 
202
  border='0' height='32'  alt='Up One Level' width='32'></A></td>
 
203
<td><a rel="next" title="4.3 Overview of a" 
 
204
  rel="next" title="4.3 Overview of a" 
 
205
  href="pyapi-filter.html"><img src='next.gif'
 
206
  border='0' height='32'  alt='Next Page' width='32'></A></td>
199
207
<td align="center" width="100%">Mod_python Manual</td>
200
 
<td><A href="contents.html"><img src="icons/contents.gif"
201
 
  border="0" height="32"
202
 
  alt="Contents" width="32"></A></td>
203
 
<td><img src="icons/blank.gif"
204
 
  border="0" height="32"
205
 
  alt="" width="32"></td>
206
 
<td><A href="genindex.html"><img src="icons/index.gif"
207
 
  border="0" height="32"
208
 
  alt="Index" width="32"></A></td>
 
208
<td><a rel="contents" title="Table of Contents" 
 
209
  rel="contents" title="Table of Contents" 
 
210
  href="contents.html"><img src='contents.gif'
 
211
  border='0' height='32'  alt='Contents' width='32'></A></td>
 
212
<td><img src='blank.gif'
 
213
  border='0' height='32'  alt='' width='32'></td>
 
214
<td><a rel="index" title="Index" 
 
215
  rel="index" title="Index" 
 
216
  href="genindex.html"><img src='index.gif'
 
217
  border='0' height='32'  alt='Index' width='32'></A></td>
209
218
</tr></table>
210
 
<b class="navlabel">Previous:</b> <a class="sectref" href="pyapi-interps.html">4.1 Multiple Interpreters</A>
211
 
<b class="navlabel">Up:</b> <a class="sectref" href="pythonapi.html">4. Python API</A>
212
 
<b class="navlabel">Next:</b> <a class="sectref" href="pyapi-filter.html">4.3 Overview of a</A>
 
219
<b class="navlabel">Previous:</b>
 
220
<a class="sectref" rel="prev" href="pyapi-interps.html">4.1 Multiple Interpreters</A>
 
221
<b class="navlabel">Up:</b>
 
222
<a class="sectref" rel="parent" href="pythonapi.html">4. Python API</A>
 
223
<b class="navlabel">Next:</b>
 
224
<a class="sectref" rel="next" href="pyapi-filter.html">4.3 Overview of a</A>
213
225
<hr>
214
 
<span class="release-info">Release 3.1.3, documentation updated on February 17, 2004.</span>
 
226
<span class="release-info">Release 3.2.10, documentation updated on July 19, 2006.</span>
215
227
</DIV>
216
228
<!--End of Navigation Panel-->
217
229