Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / howto / listings / pb / pb2server.py
1 #!/usr/bin/env python
2
3 # Copyright (c) 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 was given", arg
12         
13 class One(pb.Root):
14     def __init__(self, two):
15         #pb.Root.__init__(self)   # pb.Root doesn't implement __init__
16         self.two = two
17     def remote_getTwo(self):
18         print "One.getTwo(), returning my two called", self.two
19         return self.two
20     def remote_checkTwo(self, newtwo):
21         print "One.checkTwo(): comparing my two", self.two
22         print "One.checkTwo(): against your two", newtwo
23         if self.two == newtwo:
24             print "One.checkTwo(): our twos are the same"
25         
26
27 two = Two()
28 root_obj = One(two)
29 reactor.listenTCP(8800, pb.PBServerFactory(root_obj))
30 reactor.run()