[REF] netsvc: comments (kind of notes to self).

bzr revid: vmt@openerp.com-20110729145609-cbzlre0rsfxld3xq
This commit is contained in:
Vo Minh Thu 2011-07-29 16:56:09 +02:00
parent 40bde558c5
commit ee12a9c9c5
2 changed files with 11 additions and 1 deletions

View File

@ -116,6 +116,8 @@ class ExportService(object):
def getService(cls,name):
return cls._services[name]
# Dispatch a RPC call w.r.t. the method name. The dispatching
# w.r.t. the service (this class) is done by OpenERPDispatcher.
def dispatch(self, method, auth, params):
raise Exception("stub dispatch at %s" % self.__name)
@ -397,6 +399,11 @@ def log(title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
logger.log(channel, indent+line)
indent=indent_after
# This class is used to dispatch a RPC to a service. So it is used
# for both XMLRPC (with a SimpleXMLRPCRequestHandler), and NETRPC.
# The service (ExportService) will then dispatch on the method name.
# This can be re-written as a single function
# def dispatch(self, service_name, method, params, auth_provider).
class OpenERPDispatcher:
def log(self, title, msg, channel=logging.DEBUG_RPC, depth=None, fn=""):
log(title, msg, channel=channel, depth=depth, fn=fn)

View File

@ -213,7 +213,8 @@ class BaseHttpDaemon(threading.Thread, netsvc.Server):
return ret
# No need for these two classes: init_server() below can initialize correctly
# directly the BaseHttpDaemon class.
class HttpDaemon(BaseHttpDaemon):
_RealProto = 'HTTP'
def __init__(self, interface, port):
@ -270,6 +271,8 @@ def list_http_services(protocol=None):
raise Exception("Incorrect protocol or no http services")
import SimpleXMLRPCServer
# Basically, this class extends SimpleXMLRPCRequestHandler to use
# OpenERPDispatcher as the dispatcher (to select the correct ExportService).
class XMLRPCRequestHandler(netsvc.OpenERPDispatcher,FixSendError,HttpLogHandler,SimpleXMLRPCServer.SimpleXMLRPCRequestHandler):
rpc_paths = []
protocol_version = 'HTTP/1.1'