Suppose I want to make a networked stockroom program with perspective broker. We have a user side client object,
class Client(pb.Referenceable): def connect(self): # host, port, factory, and credentials come from elsewhere reactor.connectTCP(host, port, factory) d = self.factory.login(credentials, self) d.addCallback(self.connected) def connected(self, perspective): if perspective: self.perspective = perspective and a "corresponding" server side User, class User(pb.Avatar): def __init__(self, name, server, mind): self.name = name self.server = server self.client = mind #This is a remote reference to a Client def logout(self): ...logic... We have the IRealm implementer, @implementer(portal.IRealm) class Server(object): """I manage games and produce Avatars""" def __init__(self, loggingPath): self.users = {} self.stockrooms = set() def requestAvatar(self, avatarId, mind, *interfaces): assert pb.IPerspective in interfaces user = self.users.setdefault(avatarId, User(avatarId, self, mind)) return pb.IPerspective, user, user.logout and finally we have the Stockroom class Stockroom(object): ...logic... Now I'd like for my Clients to be able to remove/add items to the stockroom. Using only the code above I'd have to add perspective_* methods to the User. These methods would direct the Client's intent to the appropriate Stockroom. Changes made to the Stockroom would then have to be announced to any interested Clients by invoking the appropriate Users' mind property. This seems very awkward. I'd rather just have the Stockrooms be Viewable so that Clients can invoke methods on them directly. If the Stockroom were _also_ Cacheable then changes on a Stockroom would automatically propagate to the client process. Is simultaneously sub-classing Viewable and Cacheable a good idea? Am I thinking about this properly? Regards and thanks in advance, Daniel Sank -- Department of Physics Broida Hall University of California Santa Barbara, CA 93117 (805)893-3899 _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python