Package twisted :: Package spread :: Module pb :: Class Perspective
[show private | hide private]
[frames | no frames]

Class Perspective

Perspective --+
              |
             Perspective

Known Subclasses:
Perspective, Participant, MotherService, MotherService, SisterService, MeterMaid, DummyPerspective, SimplePerspective

A perspective on a service.

per*spec*tive, n. : The relationship of aspects of a subject to each other and to a whole: 'a perspective of history'; 'a need to view the problem in the proper perspective'.

A service represents a collection of state, plus a collection of perspectives. Perspectives are the way that networked clients have a 'view' onto an object, or collection of objects on the server.

Although you may have a service onto which there is only one perspective, the common case is that a Perspective will be analagous to (or the same as) a "user"; if you are creating a PB-enabled service, your User (or equivalent) class should subclass Perspective.

Initially, a peer requesting a perspective will receive only a RemoteReference to a Perspective. When a method is called on that RemoteReference, it will translate to a method on the remote perspective named 'perspective_methodname'. (For more information on invoking methods on other objects, see flavors.ViewPoint.)
Method Summary
  __init__(self, perspectiveName, identityName)
Create me. (inherited from Perspective)
  attached(self, reference, identity)
Called when a remote reference is 'attached' to me. (inherited from Perspective)
  brokerAttached(self, reference, identity, broker)
An intermediary method to override.
  brokerDetached(self, reference, identity, broker)
See brokerAttached.
  detached(self, reference, identity)
Called when a broker is 'detached' from me. (inherited from Perspective)
  getIdentityRequest(self)
Request my identity. (inherited from Perspective)
  getPerspectiveName(self)
Return the unique name of this perspective. (inherited from Perspective)
  getService(self)
Return a service. (inherited from Perspective)
  makeIdentity(self, password)
Make an identity from this perspective with a password. (inherited from Perspective)
  perspectiveMessageReceived(self, broker, message, args, kw)
This method is called when a network message is received.
  setIdentity(self, ident)
Determine which identity I connect to. (inherited from Perspective)
  setIdentityName(self, name)
(inherited from Perspective)
  setService(self, service)
Change what service I am a part of. (inherited from Perspective)

Method Details

brokerAttached(self, reference, identity, broker)

An intermediary method to override.

Normally you will want to use 'attached', as described in twisted.cred.perspective.Perspective.attached; however, this method serves the same purpose, and in some circumstances, you are sure that the protocol that objects will be attaching to your Perspective with is Perspective Broker, and in that case you may wish to get the Broker object they are connecting with, for example, to determine what host they are connecting from. Bear in mind that when overriding this method, other, non-PB protocols will not notify you of being attached or detached.

brokerDetached(self, reference, identity, broker)

See brokerAttached.

perspectiveMessageReceived(self, broker, message, args, kw)

This method is called when a network message is received.

I will call:
 |  self.perspective_%(message)s(*broker.unserialize(args),
 |                               **broker.unserialize(kw))
to handle the method; subclasses of Perspective are expected to implement methods of this naming convention.

Generated by Epydoc 1.2 prerelease on Wed Jan 29 06:26:06 2003 http://epydoc.sf.net