Developpez.com

Python

Choisissez la catégorie, puis la rubrique :

18.18.3 RequestHandler Objects

18.18.3 RequestHandler Objects

The request handler class must define a new handle() method, and can override any of the following methods. A new instance is created for each request.

finish( )
Called after the handle() method to perform any clean-up actions required. The default implementation does nothing. If setup() or handle() raise an exception, this function will not be called.

handle( )
This function must do all the work required to service a request. The default implementation does nothing. Several instance attributes are available to it; the request is available as self.request; the client address as self.client_address; and the server instance as self.server, in case it needs access to per-server information.

The type of self.request is different for datagram or stream services. For stream services, self.request is a socket object; for datagram services, self.request is a string. However, this can be hidden by using the request handler subclasses StreamRequestHandler or DatagramRequestHandler, which override the setup() and finish() methods, and provide self.rfile and self.wfile attributes. self.rfile and self.wfile can be read or written, respectively, to get the request data or return data to the client.

setup( )
Called before the handle() method to perform any initialization actions required. The default implementation does nothing.
See About this document... for information on suggesting changes.
Contacter le responsable de la rubrique Python

Partenaire : Hébergement Web