Package twisted :: Package sibling :: Module loginserv :: Class LoginService

[show private | hide private]
[frames | no frames]

## Class LoginService

    OriginalAccessor --+
                       |
           Versioned --+
                       |
      ApplicationService --+
                           |
                     Service --+
                               |
                         Service --+
                                   |
                                  LoginService

The Sibling Login service. This service knows how to load clients. The login sequence for a client is:

- client connects to login service
- login service loads their identity/perspective
- mother service remoteloads the identity on the sibling and returns a ticket
- login service passes ticket down to client
- player connects to sibling service with ticket
- player disconnects from login service

later on:

- client disconnects from sibling service
- sibling tells mother to unload the client identity

This service should run in the same process as a twisted.mother service. The mother service handles logins from siblings while this LoginService handles logins from clients.

This service enforces a single simultaneous login per-identity.

Method Summary
| `__init__(self, name, application, motherService)`
| `__delattr__(self, k)` (inherited from `OriginalAccessor`)
| `__getattr__(self, k)` (inherited from `OriginalAccessor`)
| ``__getstate__`(self, dict)` Get state, adding a version number to it on its way out. (inherited from `Versioned`)
| `__setattr__(self, k, v)` (inherited from `OriginalAccessor`)
| `__setstate__(self, state)` (inherited from `Versioned`)
| ``addPerspective`(self, perspective)` Add a perspective to this Service. (inherited from `Service`)
| ``cachePerspective`(self, perspective)` Cache a perspective loaded from an external data source. (inherited from `Service`)
| ``createPerspective`(self, name)` Create a perspective from self.perspectiveClass and add it to this service. (inherited from `Service`)
| ``disownServiceParent`(self)` Have my parent disown me. (inherited from `ApplicationService`)
| `get_application(self)` (inherited from `ApplicationService`)
| ``getPerspectiveForIdentity`(self, name, identity)` Fail if the player is already on-line.
| ``getPerspectiveNamed`(self, name)` Return a perspective that represents a user for this service. (inherited from `Service`)
| ``getPerspectiveRequest`(self, name)` Return a Deferred which is a request for a perspective on this service. (inherited from `Service`)
| ``getServiceName`(self)` The name of this service. (inherited from `Service`)
| ``getServiceType`(self)` Get a string describing the type of this service. (inherited from `Service`)
| ``loadIdentityForSibling`(self, sibling, name, identity)` Utility method for loading the remote identity once it is known which sibling the identity should be loaded on.
| ``loadLoginPerspective`(self, name, identity)` This must return a deferred that yields a perspective object.
Deferred Perspective | ``loadPerspective`(self, name)` Load a perspective from an external data-source. (inherited from `Service`)
| ``reallyDel`(self, k)` *actually* del self.k without incurring side-effects. (inherited from `OriginalAccessor`)
| ``reallySet`(self, k, v)` *actually* set self.k to v without incurring side-effects. (inherited from `OriginalAccessor`)
| `set_application(self, application)` (inherited from `ApplicationService`)
| `setApplication(self, application)` (inherited from `ApplicationService`)
| ``setServiceParent`(self, serviceParent)` Set my parent, which must be a service collection of some kind. (inherited from `ApplicationService`)
| ``startService`(self)` This call is made as a service starts up. (inherited from `ApplicationService`)
| ``stopService`(self)` This call is made before shutdown. (inherited from `ApplicationService`)
| ``uncachePerspective`(self, perspective)` Uncache a perspective loaded from an external data source. (inherited from `Service`)
| `upgradeToVersion1(self)` (inherited from `ApplicationService`)
| ``versionUpgrade`(self)` (internal) Do a version upgrade. (inherited from `Versioned`)
| `_cbPerspective(self, perspective)`

Method Details

### getPerspectiveForIdentity(self, name, identity)

Fail if the player is already on-line.

### loadIdentityForSibling(self, sibling, name, identity)

Utility method for loading the remote identity once it is known which sibling the identity should be loaded on. Should be called from within the loadLoginPerspective block.

This returns (ticket, host, port, sibling) which must be used by the client to login to the sibling server.

### loadLoginPerspective(self, name, identity)

This must return a deferred that yields a perspective object. Within this block, loadIdentityForSibling should be called. This block of functionality is broken out like this so that the decision as to which sibling to load the perspective on can be deferred, as well as the loading of the perspective itself being deferred.

example:

       def loadLoginPerspective(self, name, identity):
           d1 = defer.Deferred()
           sibling = choice(self.motherService.siblings)
           d2 = self.loadIdentityForSibling(sibling, name, identity)
           d2.addCallback(self._cbTicket, name, d1)
           return d1

       def _cbTicket(self, data, name, d1):
           newPerspective = MyPerspective(name)
           p.setTicket(data)
           d1.callback(newPerspective)

In the example, the choosing of sibling servers is not asychronous, but this framework allows it to be.

Generated by Epydoc 1.1 on Thu May 8 13:19:00 2003 | http://epydoc.sf.net