From 9570ed459f2f56ca4da7f938945d9e240acf684a Mon Sep 17 00:00:00 2001 From: scrat Date: Mon, 23 Jun 2008 20:24:58 +0000 Subject: [PATCH] changed rpcapi.py and rpcserver to support the remoteCall call schema properly (was first implemented wrong with the server having the callRemote method, which actually should be part of the xmlrpc.Proxy). git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2720 fd906abe-77d9-0310-91a1-e0d9ade77398 --- agent/system/rpcapi.py | 7 +-- agent/testing/rpcserver.py | 90 +++++++++++++++++++++++++++++++++----- 2 files changed, 81 insertions(+), 16 deletions(-) diff --git a/agent/system/rpcapi.py b/agent/system/rpcapi.py index 2a89df6..9c99e25 100644 --- a/agent/system/rpcapi.py +++ b/agent/system/rpcapi.py @@ -25,9 +25,6 @@ $Id: rpcapi.py def setup(config): global xmlrpc if config.transportserver.xmlrpc == 'testing': - from cybertools.agent.testing.rpcserver import RPCServer + from cybertools.agent.testing.rpcserver import RPCServer, xmlrpc else: - try: - from twisted.web import xmlrpc - except ImportError: - from cybertools.agent.testing.rpcserver import RPCServer \ No newline at end of file + from twisted.web import xmlrpc \ No newline at end of file diff --git a/agent/testing/rpcserver.py b/agent/testing/rpcserver.py index 077e2ef..208ab93 100644 --- a/agent/testing/rpcserver.py +++ b/agent/testing/rpcserver.py @@ -22,6 +22,8 @@ Fake rpcserver for testing purposes $Id$ """ +from twisted.internet.defer import succeed + class RPCServer(object): serverURL = '' @@ -40,23 +42,89 @@ class RPCServer(object): self.password = password self.controller = controlObj - def callRemote(self, methodName, *params): - """ - intended to simulate the callRemote command of a real xmlrpcserver - that takes a method name and calls the method, returning the results - as xml formatted strings - """ - method = getattr(self, methodName) - return method(*params) - def getMetadata(self, metadata): if self.controller is not None: # pass metadata to controller # this is done AFTER the resource (like e.g. file or mail) # is handed over pass - return "Metadata received!" + deferred = defer.succeed('Metadata accepted by server') + return deferred def xmlrpc_shutdownRPCServer(): return "xmlrRPC server shutdown completed!" - \ No newline at end of file + + +class xmlrpc(object): + + Proxy = None + XMLRPC = None + Handler = None + XMLRPCIntrospection = None + QueryProtocol = None + _QueryFactory = None + + def __init__(self): + self.Proxy = Proxy() + self.XMLRPC = XMLRPC() + self.Handler = Handler() + self.XMLRPCIntrospection = XMLRPCIntrospection() + self.QueryProtocol = QueryProtocol() + self._QueryFactory = _QueryFactory() + + def addIntrospection(self, xmlrpc): + pass + +class Proxy(object): + + url = '' + user = None + password = None + allowNone = False + queryFactory = None + + def __init__(self, url, user=None, password=None, allowNone=False): + self.url = url + self.user = user + self.password = password + self.allowNone = allowNone + self.RPCServer = RPCServer() + + def callRemote(self, methodName, *params): + """ + intended to simulate the callRemote command of a real xmlrpcserver + that takes a method name and calls the method, returning the results + as xml formatted strings + """ + method = getattr(self.RPCServer, methodName) + return method(*params) + + +class XMLRPC(object): + + def __init__(self): + pass + + +class Handler(object): + + def __init__(self): + pass + + +class XMLRPCIntrospection(object): + + def __init__(self): + pass + + +class QueryProtocol(object): + + def __init__(self): + pass + + +class _QueryFactory(object): + + def __init__(self): + pass