Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > SimpleXMLRPCServer

Reply
Thread Tools

SimpleXMLRPCServer

 
 
dcrespo
Guest
Posts: n/a
 
      10-26-2005
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_addres s = 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: SimpleXMLRPCServer whitekid Python 3 01-16-2004 08:48 PM
SimpleXMLRPCServer Maxim Khesin Python 3 01-16-2004 05:06 PM
xmlrpc / SimpleXMLRPCServer and multi-threading Marco Aschwanden Python 2 12-29-2003 06:28 PM
SimpleXMLRPCServer vs handlername question Raaijmakers, Vincent \(IndSys,GE Interlogix\) Python 1 12-20-2003 12:26 AM
Asynchronous SimpleXMLRpcServer Guyon Morée Python 3 12-04-2003 02:00 AM



Advertisments