From ee12a9c9c54984b3e9b09bdb86007e8d87adb778 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 29 Jul 2011 16:56:09 +0200 Subject: [PATCH] [REF] netsvc: comments (kind of notes to self). bzr revid: vmt@openerp.com-20110729145609-cbzlre0rsfxld3xq --- openerp/netsvc.py | 7 +++++++ openerp/service/http_server.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index f3c13535d6f..6125f2218b3 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -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) diff --git a/openerp/service/http_server.py b/openerp/service/http_server.py index 61713e9f2dd..d22d32aabeb 100644 --- a/openerp/service/http_server.py +++ b/openerp/service/http_server.py @@ -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'