SimpleXMLRPCServer

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dcrespo

    #1

    SimpleXMLRPCServer

    Hello,

    Here's my SimpleXMLRPCSer ver 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(Si mpleXMLRPCServe r):

    def __init__(self,s ocket,lock):
    self.bUsarFunci onesXMLRPCPriva das = False
    SimpleXMLRPCSer ver.__init__(se lf, socket)
    SocketServer.Th readingTCPServe r.allow_reuse_a ddress = True
    SocketServer.Th readingTCPServe r.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.acqui re()
    self.QuitFlag = 0
    self.lock.relea se()

    def get_request(sel f):
    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(s ocklist, [], [], self.timeout)
    self.lock.acqui re()
    time_to_quit = self.QuitFlag
    self.lock.relea se()
    if time_to_quit:
    raise TimeToQuit # Get out now
    if ready[0]: # A socket was ready to read
    return
    SocketServer.Th readingTCPServe r.get_request(s elf)
    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,cl ient_address):

    if TrustedHost(cli ent_address):
    return True
    return False

    def test_xmlrpc(sel f):
    return "xmlrpc works"

    Thanks,

    Daniel

Working...