~justin-fathomdb/nova/justinsb-openstack-api-volumes

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/core/howto/listings/pb/pb2server.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 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", two
 
19
        return 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 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()