[Twisted-Python] PB checkers bug?

Steve Freitas sflist at ihonk.com
Thu Jul 28 00:22:50 EDT 2005

Hi all,

I didn't get a reply to my earlier post about inventing mad crazy
checkers, so I decided to just use the IUsernamePassword interface, but
I'm stuck, because it appears PB won't allow me to use only that
interface. If I try, it dies like this:

Traceback (most recent call last):
Failure: twisted.cred.error.UnhandledCredentials: No checker for

To reproduce the error, all you have to do is tweak
InMemoryUsernamePasswordDatabaseDontUse to only implement
IUsernamePassword. I've prepared the code below for a client and a
server to demonstrate the issue. Am I just missing something? If not,
should the inability to use IUsernamePassword alone be filed as a bug?





This is the server:

from twisted.cred import checkers, credentials, portal
from twisted.internet import reactor
from twisted.spread import pb
from zope import interface

class MyRealm:
    __implements__ = portal.IRealm
    def requestAvatar(self, avatarId, mind, *interfaces):
        print "Success! We'll never get here. :-("
        return pb.IPerspective, pb.Avatar(), lambda: reactor.stop()

# So we use a simple checker...
the_checker = \
# ...and now let's perform the problematic modification:
the_checker.credentialInterfaces = (credentials.IUsernamePassword,)

the_realm = MyRealm()
the_portal = portal.Portal(the_realm)
the_factory = pb.PBServerFactory(the_portal)
reactor.listenTCP(8800, the_factory)


This is the client:

from twisted.spread import pb
from twisted.internet import reactor
from twisted.python import log
from twisted.cred import credentials
import sys
log.startLogging(sys.stdout, 0)

the_factory = pb.PBClientFactory()
reactor.connectTCP('localhost', 8800, the_factory)
d = the_factory.login(credentials.UsernamePassword('client1', 'abc'))
d.addCallback(lambda x: log.msg('Success! Won\'t happen.'))
d.addErrback(lambda x: log.msg('We died:', x))

Steve Freitas <sflist at ihonk.com>

More information about the Twisted-Python mailing list