[Twisted-Python] Providing perspective-dependent client-side information to a pb.RemoteCache object

Patrik Blommaskog pb_twisted at olga.mine.nu
Thu Jul 31 15:49:17 EDT 2003


Hmm, I find it hard to describe it as a short subject, but here's what I
seek to do:

On the server, I have the structure:

class A(pb.Cacheable):
    [...]

class B(pb.Cacheable):
    def __init__():
        self.stuff = A()	# This attribute gets replicated.


And on the client side, there are the corresponding pb.RemoteCache classes.

When an instance of B is replicated, a client-side A gets instantiated and
its setCopyableState is called, and the client-side B instance gets its
reference to it.

So far, so good.

But when the client-side A is created and its state has been set, I also
want to perform some other processing which requires references to other
parts of the client. I would prefer not to make these parts into globals.
For example, it could be dependent on the client-side perspective it
communicates through, which would be handy if the client connects to
multiple servers.

I'd like to know if there is an accepted idiom for supplying this? For
example, I believe it would have worked if the setCopyableState received the
perspective as a third parameter.






More information about the Twisted-Python mailing list