Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / lib / node537.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="node536.html" />
13<link rel="parent" href="module-SocketServer.html" />
14<link rel="next" href="module-BaseHTTPServer.html" />
15<meta name='aesop' content='information' />
16<title>11.16.3 RequestHandler Objects</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="11.16.2 Server Objects"
24 href="node536.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="11.16 SocketServer "
27 href="module-SocketServer.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="11.17 BaseHTTPServer "
30 href="module-BaseHTTPServer.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="node536.html">11.16.2 Server Objects</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module-SocketServer.html">11.16 SocketServer </A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-BaseHTTPServer.html">11.17 BaseHTTPServer </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION00131630000000000000000">
5511.16.3 RequestHandler Objects</A>
56</H2>
57
58<P>
59The request handler class must define a new <tt class="method">handle()</tt> method,
60and can override any of the following methods. A new instance is
61created for each request.
62
63<P>
64<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
65 <td><nobr><b><tt id='l2h-3565' xml:id='l2h-3565' class="function">finish</tt></b>(</nobr></td>
66 <td><var></var>)</td></tr></table></dt>
67<dd>
68Called after the <tt class="method">handle()</tt> method to perform any clean-up
69actions required. The default implementation does nothing. If
70<tt class="method">setup()</tt> or <tt class="method">handle()</tt> raise an exception, this
71function will not be called.
72</dl>
73
74<P>
75<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
76 <td><nobr><b><tt id='l2h-3566' xml:id='l2h-3566' class="function">handle</tt></b>(</nobr></td>
77 <td><var></var>)</td></tr></table></dt>
78<dd>
79This function must do all the work required to service a request.
80The default implementation does nothing.
81Several instance attributes are available to it; the request is
82available as <tt class="member">self.request</tt>; the client address as
83<tt class="member">self.client_address</tt>; and the server instance as
84<tt class="member">self.server</tt>, in case it needs access to per-server
85information.
86
87<P>
88The type of <tt class="member">self.request</tt> is different for datagram or stream
89services. For stream services, <tt class="member">self.request</tt> is a socket
90object; for datagram services, <tt class="member">self.request</tt> is a string.
91However, this can be hidden by using the request handler subclasses
92<tt class="class">StreamRequestHandler</tt> or <tt class="class">DatagramRequestHandler</tt>, which
93override the <tt class="method">setup()</tt> and <tt class="method">finish()</tt> methods, and
94provide <tt class="member">self.rfile</tt> and <tt class="member">self.wfile</tt> attributes.
95<tt class="member">self.rfile</tt> and <tt class="member">self.wfile</tt> can be read or written,
96respectively, to get the request data or return data to the client.
97</dl>
98
99<P>
100<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
101 <td><nobr><b><tt id='l2h-3567' xml:id='l2h-3567' class="function">setup</tt></b>(</nobr></td>
102 <td><var></var>)</td></tr></table></dt>
103<dd>
104Called before the <tt class="method">handle()</tt> method to perform any
105initialization actions required. The default implementation does
106nothing.
107</dl>
108
109<DIV CLASS="navigation">
110<div class='online-navigation'>
111<p></p><hr />
112<table align="center" width="100%" cellpadding="0" cellspacing="2">
113<tr>
114<td class='online-navigation'><a rel="prev" title="11.16.2 Server Objects"
115 href="node536.html"><img src='../icons/previous.png'
116 border='0' height='32' alt='Previous Page' width='32' /></A></td>
117<td class='online-navigation'><a rel="parent" title="11.16 SocketServer "
118 href="module-SocketServer.html"><img src='../icons/up.png'
119 border='0' height='32' alt='Up One Level' width='32' /></A></td>
120<td class='online-navigation'><a rel="next" title="11.17 BaseHTTPServer "
121 href="module-BaseHTTPServer.html"><img src='../icons/next.png'
122 border='0' height='32' alt='Next Page' width='32' /></A></td>
123<td align="center" width="100%">Python Library Reference</td>
124<td class='online-navigation'><a rel="contents" title="Table of Contents"
125 href="contents.html"><img src='../icons/contents.png'
126 border='0' height='32' alt='Contents' width='32' /></A></td>
127<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
128 border='0' height='32' alt='Module Index' width='32' /></a></td>
129<td class='online-navigation'><a rel="index" title="Index"
130 href="genindex.html"><img src='../icons/index.png'
131 border='0' height='32' alt='Index' width='32' /></A></td>
132</tr></table>
133<div class='online-navigation'>
134<b class="navlabel">Previous:</b>
135<a class="sectref" rel="prev" href="node536.html">11.16.2 Server Objects</A>
136<b class="navlabel">Up:</b>
137<a class="sectref" rel="parent" href="module-SocketServer.html">11.16 SocketServer </A>
138<b class="navlabel">Next:</b>
139<a class="sectref" rel="next" href="module-BaseHTTPServer.html">11.17 BaseHTTPServer </A>
140</div>
141</div>
142<hr />
143<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
144</DIV>
145<!--End of Navigation Panel-->
146<ADDRESS>
147See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
148</ADDRESS>
149</BODY>
150</HTML>