3
# Copyright (c) 2009 Twisted Matrix Laboratories.
4
# See LICENSE for details.
6
from zope.interface import implements
8
from twisted.spread import pb
9
from twisted.cred import checkers, portal
10
from twisted.internet import reactor
12
class MyPerspective(pb.Avatar):
13
def __init__(self, name):
15
def perspective_foo(self, arg):
16
print "I am", self.name, "perspective_foo(",arg,") called on", self
19
implements(portal.IRealm)
20
def requestAvatar(self, avatarId, mind, *interfaces):
21
if pb.IPerspective not in interfaces:
22
raise NotImplementedError
23
return pb.IPerspective, MyPerspective(avatarId), lambda:None
25
p = portal.Portal(MyRealm())
26
c = checkers.InMemoryUsernamePasswordDatabaseDontUse(user1="pass1",
29
reactor.listenTCP(8800, pb.PBServerFactory(p))