From 6000b6b5c62181d25783b6d45adb2ed6f3928480 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 2 Oct 2008 17:02:24 -0600 Subject: [PATCH] Implemented basic Command.forward() method --- ipalib/frontend.py | 6 +++--- ipalib/plugins/f_user.py | 8 ++++---- simple-server.py | 22 +++++++++++----------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 30f5942b9..6decb17db 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -542,9 +542,9 @@ class Command(plugable.Plugin): print ' kw =', kw def forward(self, *args, **kw): - print '%s.execute():' % self.name - print ' args =', args - print ' kw =', kw + xmlrpc_client = self.api.Backend.xmlrpc.get_client() + return getattr(xmlrpc_client, self.name)(kw, *args) + def __call__(self, *args, **kw): if len(args) > 0: diff --git a/ipalib/plugins/f_user.py b/ipalib/plugins/f_user.py index a482a963d..29f0f8a07 100644 --- a/ipalib/plugins/f_user.py +++ b/ipalib/plugins/f_user.py @@ -87,10 +87,10 @@ api.register(user_mod) class user_find(crud.Find): 'Search the users.' - def execute(self, *args, **kw): - uid=args[0] - result = servercore.get_sub_entry(servercore.basedn, "uid=%s" % uid, ["*"]) - return result +# def execute(self, *args, **kw): +# uid=args[0] +# result = servercore.get_sub_entry(servercore.basedn, "uid=%s" % uid, ["*"]) +# return result api.register(user_find) diff --git a/simple-server.py b/simple-server.py index b9de57985..02635f7dd 100755 --- a/simple-server.py +++ b/simple-server.py @@ -25,22 +25,22 @@ from ipalib import load_plugins api.finalize() +class Dispatch(object): + def __init__(self, cmd): + self.__cmd = cmd -def test_func(*args, **kw): - 'A test function' - print args, kw - return '%s, %s' % (repr(args), repr(kw)) + def __call__(self, *params): + if len(params) > 0: + kw = params[0] + else: + kw = {} + args = params[1:] + return cmd(*args, **kw) -def stuff(first, last): - 'Do stuff' - print first, last - return first + last server = SimpleXMLRPCServer(('localhost', 8080)) server.register_introspection_functions() -#server.register_function(test_func) -#server.register_function(stuff) for cmd in api.Command(): - server.register_function(cmd, cmd.name) + server.register_function(Dispatch(cmd), cmd.name) server.serve_forever()