[Twisted-Python] Intra-process callRemote
![](https://secure.gravatar.com/avatar/9011310c6d9d5fcbf4b52d9d96ceb5e8.jpg?s=120&d=mm&r=g)
I've got an arrangement where the obvious way to do things is with a Viewable... class StorageThing(pb.Viewable): def view_setMessage(self, who, what): self._store[who.identityName] = what class Who(pb.Perspective): def setMyMessage(self, what): self.storageView.callRemote("setMessage", what) only, it turns out that some of the "who"s don't really need to be in a seperate process from the Viewable; storageView is actually a reference to a ViewPoint instead of a *remote* reference to a ViewPoint, and ViewPoints don't have callRemote (because, well, they're not remote). I don't know, maybe PB just isn't quite as transparent as I desire it to be. I did so much like the idea of writing this code to communicate locally now, and just being able to drop in remote objects instead later. I could of course do def setMyMessage(self, what): self.storageView.view_setMessage(self, what) but that doesn't look nearly as elegant, and I'll have to make duplicate code with a callRemote if storageView ever becomes remote. "Still-trying-to-get-this-distributed-object-thing"-ly, - Kevin -- The moon is waning gibbous, 86.0% illuminated, 18.4 days old.
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Tue, 2002-04-30 at 12:05, Kevin Turner wrote:
I've got an arrangement where the obvious way to do things is with a Viewable...
The reason that this isn't automatic is because PB has the option to *do* stuff when you send state to other people (such as tracking the fact that they have said state). In most simple cases, such as yours, it's not necessary to completely replicate PB's object-copying semantics; however, this sort of short-cut for simplicity's sake is not something the framework can make a decision about for you; trying to run certain kinds of remote code locally would break it. (Think about P2P applications that try to connect to each other by determining the other end of the connection's IP) The reason I introduced callRemote was to facilitate this sort of thing. Since the only message you expect your object to respond to is "callRemote", simply implement "callRemote" on a pseudo-ViewPoint, (similarly to twisted.spread.util.LocalAsRemote -- maybe LocalAsViewPoint?)
PB isn't supposed to be transparent. I think I've made my argument against transparency before, but it boils down to what I said above; sometimes, transparency is wrong. In the cases where it's not, it's easy to fake using Twisted. -- | <`'> | Glyph Lefkowitz: Travelling Sorcerer | | < _/ > | Lead Developer, the Twisted project | | < ___/ > | http://www.twistedmatrix.com |
![](https://secure.gravatar.com/avatar/e1554622707bedd9202884900430b838.jpg?s=120&d=mm&r=g)
On Tue, 2002-04-30 at 12:05, Kevin Turner wrote:
I've got an arrangement where the obvious way to do things is with a Viewable...
The reason that this isn't automatic is because PB has the option to *do* stuff when you send state to other people (such as tracking the fact that they have said state). In most simple cases, such as yours, it's not necessary to completely replicate PB's object-copying semantics; however, this sort of short-cut for simplicity's sake is not something the framework can make a decision about for you; trying to run certain kinds of remote code locally would break it. (Think about P2P applications that try to connect to each other by determining the other end of the connection's IP) The reason I introduced callRemote was to facilitate this sort of thing. Since the only message you expect your object to respond to is "callRemote", simply implement "callRemote" on a pseudo-ViewPoint, (similarly to twisted.spread.util.LocalAsRemote -- maybe LocalAsViewPoint?)
PB isn't supposed to be transparent. I think I've made my argument against transparency before, but it boils down to what I said above; sometimes, transparency is wrong. In the cases where it's not, it's easy to fake using Twisted. -- | <`'> | Glyph Lefkowitz: Travelling Sorcerer | | < _/ > | Lead Developer, the Twisted project | | < ___/ > | http://www.twistedmatrix.com |
participants (2)
-
Glyph Lefkowitz
-
Kevin Turner