Name
ServerProxy
Synopsis
class ServerProxy(url)If the server at the given url supports
introspection, s supplies an attribute
s
.server that in turn
supplies three methods:
-
s.server.listMethods( ) Returns a list of strings, one per each method supported by the server.
-
s.server.methodSignature(name) Returns a list of strings, each a signature of method
nameon the server. A signature string is composed of type names separated by commas: first the type of the return value, then the type of each argument. When methodnamehas no defined signature,s.server.methodSignature(name)returns some object that is not a list.-
s.server.methodHelp(name) Returns a string with help about method
name. The string can be either plain text or HTML. When the methodnamehas no defined help,s.server.methodHelp(name)returns an empty string ''.
The following example uses xmlrpclib to access
O’Reilly’s Meerkat open wire
service (see http://www.oreillynet.com/meerkat/
for more information about Meerkat) and displays the last few news
items about Python.
import xmlrpclib
proxy = xmlrpclib.ServerProxy(
'http://www.oreillynet.com/meerkat/xml-rpc/server.php')
results = proxy.meerkat.getItems({'search':'Python', 'num_items':7})
want_keys = 'title link description'.split( )
n = 0
for result in results:
n = n + 1
for key in want_keys:
print '%d. %s: %s' % (n, key.title( ), result.get(key))
printBecome an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access