[Twisted-Python] Perspective Broker Anonymous access..

Carlos Eduardo cedepaula at yahoo.com.br
Fri Dec 8 08:27:09 EST 2006

I´m just learning how to use twisted PB and playing with the chat server...

I´m trying to create a way to allow authenticated and anonymous users into the
system but can't figure how to make it.

Here what i´m trying to do:


    def requestAvatar(self, avatarId, mind, *interfaces):
        assert pb.IPerspective in interfaces
        return pb.IPerspective, MyPerspective(avatarId), lambda:None

p = portal.Portal(MyRealm())
c = checkers.InMemoryUsernamePasswordDatabaseDontUse(user1="pass1",

p.registerChecker(checkers.AllowAnonymousAccess(), credentials.Anonymous())
reactor.listenTCP(8800, pb.PBServerFactory(p))

    factory = pb.PBClientFactory()
    reactor.connectTCP("localhost", 8800, factory)
    def1 = factory.login(credentials.Anonymous())


It dont work this way, giving me this error:

Traceback (most recent call last):
Failure: twisted.cred.error.UnauthorizedLogin:

Another way i tried to register only the AllowAnonymousAccess in the server but
the following error popped:

Traceback (most recent call last):
Failure: twisted.cred.error.UnhandledCredentials: No checker for twisted.cred.cr
edentials.IUsernameHashedPassword, twisted.spread.pb.IUsernameMD5Password, twist

Looks like PB doesn´t support anonymous access but from documentation i saw that
i can do the following:

# anonymous users share one Avatar, named users each get their own
    def requestAvatar(self, avatarID, mind, *interfaces):
        assert pb.IPerspective in interfaces
        if avatarID == checkers.ANONYMOUS:
            return pb.IPerspective, self.anonAvatar, lambda:None
            return pb.IPerspective, self.avatars[avatarID], lambda:None

Just dont know how.... I already checked the PB internals (pb, portal, checkers,
credentials) and havent figured out how to add anonymous support to PB... if you
guys could help me I´m commited to add this support...

Thanks for all,

Carlos Eduardo

More information about the Twisted-Python mailing list