class FactoryMixIn: """Mix-in class to pass a factory object instead of RequestHandlerClass. New usage: - If needed, extend the __init__ method of the request handler to pass extra parameters. - Define a factory object with a method start() that instantiates a RequestHandlerClass. - Use None for the RequestHandlerClass parameter when you instantiate the server. - Before you handle the request, pass the factory object in set_factory(). """ def set_factory(self, requesthandlerfactory): """Set a factory instance that will instantiate the RequestHandlerClass.""" self.requesthandlerfactory = requesthandlerfactory def finish_request(self, request, client_address): """Finish one request by calling the request handler factory.""" self.requesthandlerfactory.start(request, client_address, self)