xmlrpc Server

Andrew ajwms at visto.com
Mon Jun 4 20:31:28 CEST 2001

"Fredrik Lundh" wrote 
> as its name implies, a request handler object handles a
> single request.

I'm with you... I kind-of thought that but I still don't trust my
newbie skills...

> to create a "persistent" object, attach it to the server
> class.  something like this could work:
>     class TestRequestHandler(xmlrpcserver.RequestHandler):
>         ...
>         def add(...):
>             self.server.x = self.server.x + value
>             return "sum = %s" % self.server.x
>     class TestServer(SocketServer.TCPServer):
>         def __init__(self, port=8000):
>             self.x = 0
>             SocketServer.TCPServer.__init__(self, ('', port), TestRequestHandler)
>     server = TestServer()
>     server.serve_forever()
> </F>

cool.  Works perfectly.  

Based on this, if I create a class to connect to a db and pull data,
then I simply need to subclass SocketServer.TCPServer, make sure I
call the SocketServer.TCPServer __init__ method in my own __init__
method and I'm off to the races... I only have to write methods in the
"TestRequestHandler" to pass off the data "TestServer"...

Thanks a lot!!

Andrew Williams

More information about the Python-list mailing list