Class: ViewPoint | Twisted-0.17.4/twisted/spread/flavors.py | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
I act as an indirect reference to an object accessed through a Perspective.Simply put, I combine an object with a perspective so that when a peer calls methods on the object I refer to, the method will be invoked with that perspective as a first argument, so that it can know who is calling it. While Viewable objects will be converted to ViewPoints by default
when they are returned from or sent as arguments to a remote
method, any object may be manually proxied as well. (XXX: Now that
this class is no longer named Proxy, this is the only occourance
of the term This can be useful when dealing with Perspectives, Copyables, and Cacheables. It is legal to implement a method as such on a perspective: | def perspective_getViewPointForOther(self, name): | defr = self.service.getPerspectiveRequest(name) | defr.addCallbacks(lambda x, self=self: ViewPoint(self, x), log.msg) | return defr This will allow you to have references to Perspective objects in two
different ways. One is through the initial The practical offshoot of this is that you can implement 2 varieties of remotely callable methods on this Perspective; view_xxx and perspective_xxx. view_xxx methods will follow the rules for ViewPoint methods (see ViewPoint.remoteMessageReceived), and perspective_xxx methods will follow the rules for Perspective methods.
|