[Twisted-Python] Must avatarId always be a string?

Itamar Turner-Trauring itamar at futurefoundries.com
Sun Jan 13 09:08:38 EST 2013

It's possible that in some of the cases discussed above, what you want is a
custom *Portal*. For example, if you want to try a sequence of logins, and
choose the first that succeeds:

class MultiPortal(object):
    def __init__(self, portals):
        self.portals = portals

    def login(self, *args, **kwargs):
        for portal in self.portals:
                return portal.login(*args, **kwargs)
        # Ran out of portals, failed to login:
        raise Unauthorized()

Or, let's say you're writing a backend that is a combination checker and
realm, where separating that two doesn't make sense. E.g. a backend for a
POP3 server that is a proxy to another POP3 server. In this case there's no
point in writing separate checker and realm, just write a new Portal:

class POP3ProxyPortal(object):
    def __init__(self, endpoint):
        self.endpoint = endpoint

    def login(self, credentials, mind, *interfaces):
        pop3client = yield self.endpoint.connect(POP3ClientFactory())
        yield pop3client.login(credentials.username, credentials.password)
        defer.returnValue((IMailbox, MailboxProxy(pop3client),

Itamar Turner-Trauring, Future Foundries LLC
http://futurefoundries.com/ — Twisted consulting, training and support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130113/1fc55900/attachment.htm 

More information about the Twisted-Python mailing list