Dynamic method name generation using xmlrpc
Question
How using Python I can dynamically generate my call to my xmlrpc server using xmlrpc
lib?
something like
def call_method(method_name)
server = Server(self.URL, transport=ProxiedTransport())
server.method_name(params)
The resolution takes method_name
instead of for example if method_name=get_time
:
server.get_time(params)
.
Solution
The source of xmlrpclib
contains this comment, which you might find applicable outside its original context.
# note: to call a remote object with an non-standard name, use
# result getattr(server, "strange-python-name")(args)
It's a general Python idiom.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow