~midokura/nova/midostack-oneiric

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/listings/pb/pb3client.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Copyright (c) 2009 Twisted Matrix Laboratories.
 
4
# See LICENSE for details.
 
5
 
 
6
from twisted.spread import pb
 
7
from twisted.internet import reactor
 
8
 
 
9
class Two(pb.Referenceable):
 
10
    def remote_print(self, arg):
 
11
        print "Two.print() called with", arg
 
12
 
 
13
def main():
 
14
    two = Two()
 
15
    factory = pb.PBClientFactory()
 
16
    reactor.connectTCP("localhost", 8800, factory)
 
17
    def1 = factory.getRootObject()
 
18
    def1.addCallback(got_obj, two) # hands our 'two' to the callback
 
19
    reactor.run()
 
20
 
 
21
def got_obj(obj, two):
 
22
    print "got One:", obj
 
23
    print "giving it our two"
 
24
    obj.callRemote("takeTwo", two)
 
25
 
 
26
main()