2
from twisted.python import util
3
from twisted.spread import pb
4
from twisted.cred import portal, checkers, credentials
6
class Avatar(pb.Avatar):
7
def perspective_exception(self, x):
11
def requestAvatar(self, interface, mind, *interfaces):
12
if pb.IPerspective in interfaces:
13
return pb.IPerspective, Avatar(), lambda: None
16
avatar.callRemote("exception", 10).addCallback(str).addCallback(util.println)
22
c = checkers.InMemoryUsernamePasswordDatabaseDontUse(user="pass")
23
p = portal.Portal(Realm(), [c])
24
server = pb.PBServerFactory(p)
25
server.unsafeTracebacks = True
26
client = pb.PBClientFactory()
27
login = client.login(credentials.UsernamePassword("user", "pass"))
28
login.addCallback(cbLogin).addErrback(ebLogin).addBoth(lambda: reactor.stop())
30
from twisted.internet import reactor
31
p = reactor.listenTCP(0, server)
32
c = reactor.connectTCP('127.0.0.1', p.getHost().port, client)
35
if __name__ == '__main__':