SimpleXMLRPCServer

Discussion in 'Python' started by dcrespo, Oct 26, 2005.

  1. dcrespo

    dcrespo Guest

    Hello,

    Here's my SimpleXMLRPCServer derived class for serving XMLRPC
    functions. Note that this class enables you to shutdown the xml-rpc
    server in the moment you want just accesing the QuitFlag variable of
    the class. I would like to add SSL functionality to that. What do I
    have to add or modify in it to do so?

    class XMLRPCServer(SimpleXMLRPCServer):

    def __init__(self,socket,lock):
    self.bUsarFuncionesXMLRPCPrivadas = False
    SimpleXMLRPCServer.__init__(self, socket)
    SocketServer.ThreadingTCPServer.allow_reuse_address = True
    SocketServer.ThreadingTCPServer.request_queue_size = 100
    self.timeout = 0.1 # Default timeout: 5.0
    seconds
    self.lock = lock # Should be a preexisting threading.RLock()
    object
    self.lock.acquire()
    self.QuitFlag = 0
    self.lock.release()

    def get_request(self):
    socklist = [self.socket]
    while 1:
    # Select with a timeout, then poll a quit flag. An
    alternate
    # approach would be to let the master thread "wake us up"
    # with a socket connection.
    ready = select.select(socklist, [], [], self.timeout)
    self.lock.acquire()
    time_to_quit = self.QuitFlag
    self.lock.release()
    if time_to_quit:
    raise TimeToQuit # Get out now
    if ready[0]: # A socket was ready to read
    return
    SocketServer.ThreadingTCPServer.get_request(self)
    else: # We timed out, no connection yet
    pass # Just go back to the select()

    def _dispatch(self, method, params):
    try:
    func = getattr(self, 'xmlrpc_' + method)
    except AttributeError:
    #return 'La funcion no existe'
    raise Exception('La Funcion "%s" no existe' % method)
    else:
    return func(*params)

    def verify_request(self,request,client_address):

    if TrustedHost(client_address):
    return True
    return False

    def test_xmlrpc(self):
    return "xmlrpc works"

    Thanks,

    Daniel
    dcrespo, Oct 26, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guyon Morée

    Asynchronous SimpleXMLRpcServer

    Guyon Morée, Dec 3, 2003, in forum: Python
    Replies:
    3
    Views:
    473
    Ng Pheng Siong
    Dec 4, 2003
  2. Raaijmakers, Vincent \(IndSys,GE Interlogix\)

    SimpleXMLRPCServer vs handlername question

    Raaijmakers, Vincent \(IndSys,GE Interlogix\), Dec 19, 2003, in forum: Python
    Replies:
    1
    Views:
    304
    Shalabh Chaturvedi
    Dec 20, 2003
  3. Marco Aschwanden
    Replies:
    2
    Views:
    791
    Shalabh Chaturvedi
    Dec 29, 2003
  4. Maxim Khesin

    SimpleXMLRPCServer

    Maxim Khesin, Jan 16, 2004, in forum: Python
    Replies:
    3
    Views:
    424
    Maxim Khesin
    Jan 16, 2004
  5. whitekid

    RE: SimpleXMLRPCServer

    whitekid, Jan 16, 2004, in forum: Python
    Replies:
    3
    Views:
    366
    The Jetman
    Jan 16, 2004
Loading...

Share This Page