This commit is contained in:
Wolfgang Hottgenroth
2007-11-16 17:45:39 +01:00
parent 825276e9b2
commit 3f3db5fcf7
3 changed files with 52 additions and 7 deletions

33
server/XmlRpcReceiver.py Normal file
View File

@ -0,0 +1,33 @@
import threading
import time
import Event
from logger import Logger
class MathServer(SimpleXMLRPCServer):
def _dispatch(self, method, params):
try:
# We are forcing the 'export_' prefix on methods that are
# callable through XML-RPC to prevent potential security
# problems
func = getattr(self, 'export_' + method)
except AttributeError:
raise Exception('method "%s" is not supported' % method)
else:
return func(*params)
def export_add(self, x, y):
return x + y
class XmlRpcReceiver(threading.Thread):
def __init__(self, xmlRpcRecvAddr):
threading.Thread.__init__(self)
self.xmlRpcRecvAddr = xmlRpcRecvAddr
self.setDaemon(True)
def run(self):
server = MathServer(self.xmlRpcAddr)
server.serve_forever()