On Tue, 11 Nov 2003, "Phil Christensen" <phil@bubblehouse.org> wrote:
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?
Others have already said that the right way is to "push, not pull": give the service object as an argument to __init__. I wanted to add that the correct way to pass the registry to UserPerspective is probably much the same thing: class UserPerspective: # ... def setRegistry(self, registry): self.registry = registry class InnerSpaceRealm: __implements__ = portal.IRealm def __init__(self, registry): self.registry = registry def requestAvatar(self, avatarId, mind, *interfaces): if pb.IPerspective in interfaces: avatar = UserPerspective(mind, self.registry.get(avatarId)) avatar.setRegistry(self.registry) return pb.IPerspective, avatar, avatar.logout else: raise NotImplementedError("no interface")