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

Peter Westlake peter.westlake at pobox.com
Mon Jan 14 06:27:33 EST 2013

Interesting... those portals could be on different Realms too. It would
also allow more than one checker to be tried per interface, which would
allow (say) a credentials.IUsernamePassword to be tried against
different checkers.


On Sun, Jan 13, 2013, at 14:08, Itamar Turner-Trauring wrote:

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,

        defer.returnValue((IMailbox, MailboxProxy(pop3client),

Itamar Turner-Trauring, Future Foundries LLC
[1]http://futurefoundries.com/ — Twisted consulting, training and


Twisted-Python mailing list

[2]Twisted-Python at twistedmatrix.com



1. http://futurefoundries.com/
2. mailto:Twisted-Python at twistedmatrix.com
3. http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130114/1adecdc3/attachment-0001.htm 

More information about the Twisted-Python mailing list