mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Implemented basic Command.forward() method
This commit is contained in:
@@ -542,9 +542,9 @@ class Command(plugable.Plugin):
|
|||||||
print ' kw =', kw
|
print ' kw =', kw
|
||||||
|
|
||||||
def forward(self, *args, **kw):
|
def forward(self, *args, **kw):
|
||||||
print '%s.execute():' % self.name
|
xmlrpc_client = self.api.Backend.xmlrpc.get_client()
|
||||||
print ' args =', args
|
return getattr(xmlrpc_client, self.name)(kw, *args)
|
||||||
print ' kw =', kw
|
|
||||||
|
|
||||||
def __call__(self, *args, **kw):
|
def __call__(self, *args, **kw):
|
||||||
if len(args) > 0:
|
if len(args) > 0:
|
||||||
|
|||||||
@@ -87,10 +87,10 @@ api.register(user_mod)
|
|||||||
|
|
||||||
class user_find(crud.Find):
|
class user_find(crud.Find):
|
||||||
'Search the users.'
|
'Search the users.'
|
||||||
def execute(self, *args, **kw):
|
# def execute(self, *args, **kw):
|
||||||
uid=args[0]
|
# uid=args[0]
|
||||||
result = servercore.get_sub_entry(servercore.basedn, "uid=%s" % uid, ["*"])
|
# result = servercore.get_sub_entry(servercore.basedn, "uid=%s" % uid, ["*"])
|
||||||
return result
|
# return result
|
||||||
api.register(user_find)
|
api.register(user_find)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,22 +25,22 @@ from ipalib import load_plugins
|
|||||||
|
|
||||||
api.finalize()
|
api.finalize()
|
||||||
|
|
||||||
|
class Dispatch(object):
|
||||||
|
def __init__(self, cmd):
|
||||||
|
self.__cmd = cmd
|
||||||
|
|
||||||
def test_func(*args, **kw):
|
def __call__(self, *params):
|
||||||
'A test function'
|
if len(params) > 0:
|
||||||
print args, kw
|
kw = params[0]
|
||||||
return '%s, %s' % (repr(args), repr(kw))
|
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 = SimpleXMLRPCServer(('localhost', 8080))
|
||||||
server.register_introspection_functions()
|
server.register_introspection_functions()
|
||||||
#server.register_function(test_func)
|
|
||||||
#server.register_function(stuff)
|
|
||||||
for cmd in api.Command():
|
for cmd in api.Command():
|
||||||
server.register_function(cmd, cmd.name)
|
server.register_function(Dispatch(cmd), cmd.name)
|
||||||
|
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
|
|||||||
Reference in New Issue
Block a user