mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 15:40:01 -06:00
Implemented basic Command.forward() method
This commit is contained in:
parent
0e137110c7
commit
6000b6b5c6
@ -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:
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user