Imported Upstream version 12.1.0
[contrib/python-twisted.git] / doc / core / howto / tutorial / listings / finger / fingerPBclient.py
1 # test the PB finger on port 8889
2 # this code is essentially the same as
3 # the first example in howto/pb-usage
4
5 from twisted.spread import pb
6 from twisted.internet import reactor
7
8 def gotObject(object):
9     print "got object:", object
10     object.callRemote("getUser","moshez").addCallback(gotData)
11 # or
12 #   object.callRemote("getUsers").addCallback(gotData)
13    
14 def gotData(data):
15     print 'server sent:', data
16     reactor.stop()
17     
18 def gotNoObject(reason):
19     print "no object:",reason
20     reactor.stop()
21
22 factory = pb.PBClientFactory()
23 reactor.connectTCP("127.0.0.1",8889, factory)
24 factory.getRootObject().addCallbacks(gotObject,gotNoObject)
25 reactor.run()
26