[Twisted-Python] an easy twisted application question

Jp Calderone exarkun at intarweb.us
Tue Nov 11 21:14:30 EST 2003

On Tue, Nov 11, 2003 at 04:28:55PM -0500, Phil Christensen wrote:
> Okay, that answers another question I had, but I'm still not clear on how
> to get at that service object from a couple of places.
> For example, here's my Realm implementation:
> class InnerSpaceRealm:
>     __implements__ = portal.IRealm
>     def requestAvatar(self, avatarId, mind, *interfaces):
>         if pb.IPerspective in interfaces:
>             registry = ### how do i get this?
>             avatar = UserPerspective(mind, registry.get(avatarId))
>             return pb.IPerspective, avatar, avatar.logout
>         else:
>             raise NotImplementedError("no interface")
> what's the right way to get that service object?

  Like so:

    class InnerSpaceRealm:
        __implements__ = portal.IRealm

        def __init__(self, service):
            self.service = service

        def requestAvatar(self, avatarId, mind, *interfaces):

  ;)  There are other ways, but I'm sure you don't need me to point them
out.  The key is, just do the obvious thing here.  There's no special way to
manage this.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20031111/95cf485a/attachment.pgp 

More information about the Twisted-Python mailing list