[Twisted-Python] Perspective Shift

Kevin Turner acapnotic at twistedmatrix.com
Tue Nov 6 17:14:43 EST 2001

In my recent inspection of passport.Perspective, I got to thinking:

My first time through Perspective Broker school, I got the impression
that a Perspective is the way a client sees a Service.  In more
practical terms, it seemed a Perspective is an object which provides the
client with an interface to the Service.  In this way a Perspective also
acts as a mediator between client and Service; not giving the client
unfettered access to the Service object, but only to methods defined in
the Perspective's interface.

So the stick figure in my head looks like this:
client <----> interface-perspective -- Service

But really, any podunk Referencable object holding a .service attribute
could do that.  Why, I wonder, all the fanfare about Perspectives? ...

Since the introduction of Passport, my understanding of Perspectives
has been shifting.  One realization is that Perspective objects aren't
transient objects which come and go with the clients who start and stop
viewing through them.  They're persistant objects, they hold state about
the "owners" they represent.  So now, slowly, Perspectives aren't just
how a client interfaces with a Service, they also are what a Service
knows about its clients.

The arrow in my stick figure begins to waver from "this thing is about a
Service" side, towards the "this thing is about a client" side.

Passport; Authorizers, Identities.  Glyph says he wants an object
representing a client's global identity, independant of any particular
service, and thus class Identity is born.  Again, Perspectives firmly
take the middle ground.  A client has an Identity, an identity which
must remain free of any Service-specific baggage.  Any aspects of a
client's state related to a particular Service go into its Perspective
to that service.

Meanwhile, Services still know nothing of Identities, still dealing only
with Perspectives.  To get to a Service though, you've now got to ask an
Authorizer.  Access is kept in the form of (service, perspective) pairs.
You *can't* treat a Perspective instance as transient and disposable
now-- were it to disappear, you might not be able to access the Service

With the latest stirring of the pot,
> In any service where you wish to migrate users across server boundaries 
> or among different simulations, you'll need some flexibility there.  

it seems that the immutable nature of the
Perspective-instance-to-Service-instance link has been cut.  Presumably
the serviceType will remain the same, even if a Perspective drifts among
Service instances.  So I guess the client's conception of "this is my
view of this service" is still accurate.  It seems though that the arrow
has swung quite far to the "this thing is about a client" side.

So, that's my evolving perspective on the evolution of Perspectives.
Partly just thinking out loud.  When I started this message, I wasn't at
all sure that Perspectives are the same thing as they used to be, but I
guess I'm satisfied for now.

If I got any of it wrong...  well, you'll let me know.

 - Kevin

The moon is waning gibbous, 70.9% illuminated, 20.1 days old.

More information about the Twisted-Python mailing list