3
from twisted.spread import pb
4
from twisted.cred import checkers, portal
5
from twisted.internet import reactor
7
class MyPerspective(pb.Avatar):
8
def __init__(self, name):
10
def perspective_foo(self, arg):
11
print "I am", self.name, "perspective_foo(",arg,") called on", self
14
__implements__ = portal.IRealm
15
def requestAvatar(self, avatarId, mind, *interfaces):
16
if pb.IPerspective not in interfaces:
17
raise NotImplementedError
18
return pb.IPerspective, MyPerspective(avatarId), lambda:None
20
p = portal.Portal(MyRealm())
21
c = checkers.InMemoryUsernamePasswordDatabaseDontUse(user1="pass1",
24
reactor.listenTCP(8800, pb.PBServerFactory(p))