Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / web / examples / xmlrpcclient.py
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 This example makes remote XML-RPC calls.
6
7 Usage:
8     $ python xmlrpcclient.py
9
10 The example will make an XML-RPC request to advogato.org and display the result.
11 """
12
13 from twisted.web.xmlrpc import Proxy
14 from twisted.internet import reactor
15
16 def printValue(value):
17     print repr(value)
18     reactor.stop()
19
20 def printError(error):
21     print 'error', error
22     reactor.stop()
23
24 def capitalize(value):
25     print repr(value)
26     proxy.callRemote('test.capitalize', 'moshe zadka').addCallbacks(printValue, printError)
27
28 proxy = Proxy('http://advogato.org/XMLRPC')
29 # The callRemote method accepts a method name and an argument list.
30 proxy.callRemote('test.sumprod', 2, 5).addCallbacks(capitalize, printError)
31 reactor.run()