Package PyFoam :: Package Infrastructure :: Module ServerBase
[hide private]
[frames] | no frames]

Source Code for Module PyFoam.Infrastructure.ServerBase

 1  #  ICE Revision: $Id$ 
 2  """Basis for the XMLRPC-Servers in PyFoam 
 3   
 4  Based on 15.5 in "Python Cookbook" for faster restarting""" 
 5   
 6  from PyFoam.ThirdParty.six import PY3 
 7   
 8  if PY3: 
 9      from xmlrpc.server import SimpleXMLRPCServer 
10  else: 
11      from SimpleXMLRPCServer import SimpleXMLRPCServer 
12   
13  import socket 
14   
15 -class ServerBase(SimpleXMLRPCServer):
16 """The Base class for the servers"""
17 - def __init__(self,addr,logRequests=False):
18 """@param addr: the (server address,port)-tuple) 19 @param logRequests: patched thru to the base class""" 20 SimpleXMLRPCServer.__init__(self,addr,logRequests=logRequests)
21
22 - def server_bind(self):
23 """Should allow a fast restart after the server was killed""" 24 self.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) 25 SimpleXMLRPCServer.server_bind(self)
26
27 - def verify_request(self,request,client_addr):
28 """To be overriden later""" 29 return True
30 31 # Should work with Python3 and Python2 32