Slide 95
Slide 95 text
class
class SimpleXMLRPCServer(SocketServer.TCPServer,
SimpleXMLRPCServer(SocketServer.TCPServer,
SimpleXMLRPCDispatcher):
SimpleXMLRPCDispatcher):
"""Simple XML-RPC server.
"""Simple XML-RPC server.
Simple XML-RPC server that allows functions and a single instance
Simple XML-RPC server that allows functions and a single instance
to be installed to handle requests. The default implementation
to be installed to handle requests. The default implementation
attempts to dispatch XML-RPC calls to the functions or instance
attempts to dispatch XML-RPC calls to the functions or instance
installed in the server. Override the _dispatch method inhereted
installed in the server. Override the _dispatch method inhereted
from SimpleXMLRPCDispatcher to change this behavior.
from SimpleXMLRPCDispatcher to change this behavior.
"""
"""
allow_reuse_address =
allow_reuse_address = True
True
# Warning: this is for debugging purposes only! Never set this to True in
# Warning: this is for debugging purposes only! Never set this to True in
# production code, as will be sending out sensitive information (exception
# production code, as will be sending out sensitive information (exception
# and stack trace details) when exceptions are raised inside
# and stack trace details) when exceptions are raised inside
# SimpleXMLRPCRequestHandler.do_POST
# SimpleXMLRPCRequestHandler.do_POST
_send_traceback_header =
_send_traceback_header = False
False
def
def __init__
__init__(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
(self, addr, requestHandler=SimpleXMLRPCRequestHandler,
logRequests=True, allow_none=False, encoding=None, bind_and_activate=True):
logRequests=True, allow_none=False, encoding=None, bind_and_activate=True):
self.logRequests = logRequests
self.logRequests = logRequests
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
SimpleXMLRPCDispatcher.__init__(self, allow_none, encoding)
SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
SocketServer.TCPServer.__init__(self, addr, requestHandler, bind_and_activate)
# [Bug #1222790] If possible, set close-on-exec flag; if a
# [Bug #1222790] If possible, set close-on-exec flag; if a
# method spawns a subprocess, the subprocess shouldn't have
# method spawns a subprocess, the subprocess shouldn't have
# the listening socket open.
# the listening socket open.
if
if fcntl
fcntl is not
is not None and hasattr(fcntl, 'FD_CLOEXEC'):
None and hasattr(fcntl, 'FD_CLOEXEC'):
flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
flags = fcntl.fcntl(self.fileno(), fcntl.F_GETFD)
flags |= fcntl.FD_CLOEXEC
flags |= fcntl.FD_CLOEXEC
fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)
fcntl.fcntl(self.fileno(), fcntl.F_SETFD, flags)