Home | Trees | Index | Help |
|
---|
Package glass :: Module HTTPServer :: Class _HTTPServer |
|
BaseServer
--+ |TCPServer
--+ | _HTTPServer
This is a replacement for BaseHTTPServer.HTTPServer.
It does all the same work BaseHTTPServer.HTTPServer does. However, instead of inheriting from something like SocketServer.ThreadingTCPServer, it inherits directly from SocketServer.TCPServer and accepts a servertype for creating sockets and threads. This is necessary to support new threading models and socket types.
This whole class is a move away from the design espoused by SocketServer toward a design suggested by Paul Clegg. Specifically, instead of using mixins for the various threading models, factories are used for both socket and thread creation.
The following attributes are used:
Method Summary | |
---|---|
Against doctor's orders, I must override (not extend) this. | |
Create, bind, and activate the socket. | |
Handle the is_secure attribute. | |
HACK: Call TCPServer.close_request, if defined. | |
Instantiate the RequestHandlerClass and run it. | |
Call finish_request, but handle exceptions. | |
Handle errors such as errno.EPIPE or errno.ECONNRESET. | |
Override this to handle socket errors from get_request. | |
Differentiate errors. | |
Handle all other errors that handle_disconnect_error doesn't. | |
Handle early socket exceptions. | |
Setup self.mounts. | |
Is e an error like errno.EPIPE or errno.ECONNRESET? | |
Call finish_request_threaded in a new "thread". | |
Extend server_bind to store the server name and port. | |
Inherited from TCPServer | |
Return socket file number. | |
Get the request and client address from the socket. | |
Called by constructor to activate the server. | |
Called to clean-up the server. | |
Inherited from BaseServer | |
Handle one request at a time until doomsday. | |
Verify the request. |
Class Variable Summary | |
---|---|
int |
allow_reuse_address = 1 |
list |
available_vfs_modules = ['Standard', 'Zip']
|
Inherited from TCPServer | |
int |
address_family = 2 |
int |
request_queue_size = 5 |
int |
socket_type = 1 |
Method Details |
---|
__init__(self,
server_address=('', 80),
RequestHandlerClass=None,
server_ctx=None,
servertype=None)
|
__call__(self)
|
__getattr__(self,
attr)
|
close_request(self, request)HACK: Call TCPServer.close_request, if defined. It isn't defined in Python 2.0, but it must be done in Python 2.3.
|
finish_request(self, request, client_address)Instantiate the RequestHandlerClass and run it. In TCPServer.finish_request, instantiating the RequestHandlerClass is sufficient to run it. However, in coro, you can't have anything in an __init__ that may lead to a context switch. SocketServer.BaseRequestHandler.__init__, unsurprisingly, is ignorant of this rule. Hence, we require that the RequestHandlerClass passed to us implement a separate __init__ and __call__ method, both of which will be called here, in order to work around this problem. This is an API change that must apply to coro and non-coro alike since it affects the request handlers.
|
finish_request_threaded(self, request, client_address)Call finish_request, but handle exceptions. This is nice because I don't won't exceptions from one "thread" being handled in another "thread". |
handle_disconnect_error(self, e, request, client_address)Handle errors such as errno.EPIPE or errno.ECONNRESET. By default, they are ignored. |
handle_early_socket_error(self, e, request, client_address)Override this to handle socket errors from get_request. By default, I output to stderr just to make sure you see something if things are completely messed up. Beware, request and client_address might each be None. |
handle_error(self, e, request, client_address)Differentiate errors. Differentiate handle_disconnect_error and handle_other_error.
|
handle_other_error(self, e, request, client_address)Handle all other errors that handle_disconnect_error doesn't. Since I don't know what's appropriate for your app, I'll just call TCPServer.handle_error. |
handle_request(self)Handle early socket exceptions. Call handle_early_socket_error.
|
init_mounts(self)Setup self.mounts. Implicitly add the document root as the first member. Pick the right vfs for each path_translated. Make sure each url_path has a trailing slash. If not, add one. |
is_disconnect_error(self, e)Is e an error like errno.EPIPE or errno.ECONNRESET? Various types of sockets might represent disconnect errors differently. Hopefully, one of the ways I've coded will apply. |
process_request(self, request, client_address)Call finish_request_threaded in a new "thread".
|
server_bind(self)Extend server_bind to store the server name and port.
|
Class Variable Details |
---|
allow_reuse_address
|
available_vfs_modules
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Jan 1 16:36:34 2007 | http://epydoc.sf.net |