Initial import to Tizen
[profile/ivi/python-twisted.git] / doc / core / howto / listings / pb / copy_receiver.tac
1 # Copyright (c) Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 PB copy receiver example.
6
7 This is a Twisted Application Configuration (tac) file.  Run with e.g.
8    twistd -ny copy_receiver.tac
9
10 See the twistd(1) man page or
11 http://twistedmatrix.com/documents/current/howto/application for details.
12 """
13
14 import sys
15 if __name__ == '__main__':
16     print __doc__
17     sys.exit(1)
18
19 from twisted.application import service, internet
20 from twisted.internet import reactor
21 from twisted.spread import pb
22 from copy_sender import LilyPond, CopyPond
23
24 from twisted.python import log
25 #log.startLogging(sys.stdout)
26
27 class ReceiverPond(pb.RemoteCopy, LilyPond):
28     pass
29 pb.setUnjellyableForClass(CopyPond, ReceiverPond)
30
31 class Receiver(pb.Root):
32     def remote_takePond(self, pond):
33         print " got pond:", pond
34         pond.countFrogs()
35         return "safe and sound" # positive acknowledgement
36     def remote_shutdown(self):
37         reactor.stop()
38
39 application = service.Application("copy_receiver")
40 internet.TCPServer(8800, pb.PBServerFactory(Receiver())).setServiceParent(
41     service.IServiceCollection(application))