Package Products :: Package ZenUtils :: Module PBUtil :: Class ReconnectingPBClientFactory |
[hide private]
[frames] | no frames]

# Class ReconnectingPBClientFactory

source code

              twisted.internet.protocol.Factory --+
                                                  |
            twisted.internet.protocol.ClientFactory --+
                                                      |
                      twisted.spread.pb.PBClientFactory --+
                                                          |
              twisted.internet.protocol.Factory --+       |
                                                  |       |
            twisted.internet.protocol.ClientFactory --+   |
                                                      |   |
    twisted.internet.protocol.ReconnectingClientFactory --+
                                                          |
                                                         ReconnectingPBClientFactory

Reconnecting client factory for PB brokers.

Like PBClientFactory, but if the connection fails or is lost, the factory will attempt to reconnect.

Instead of using f.getRootObject (which gives a Deferred that can only be fired once), override the gotRootObject method.

Instead of using the newcred f.login (which is also one-shot), call f.startLogin() with the credentials and client, and override the gotPerspective method.

Instead of using the oldcred f.getPerspective (also one-shot), call f.startGettingPerspective() with the same arguments, and override gotPerspective.

gotRootObject and gotPerspective will be called each time the object is received (once per successful connection attempt). You will probably want to use obj.notifyOnDisconnect to find out when the connection is lost.

If an authorization error occurs, failedToGetPerspective() will be invoked.

To use me, subclass, then hand an instance to a connector (like TCPClient).

Nested Classes | [hide private]
Inherited from `twisted.spread.pb.PBClientFactory`: `protocol`

Instance Methods | [hide private]
__init__(self) | source code
clientConnectionFailed(self, connector, reason) Called when a connection has failed to connect. | source code
clientConnectionLost(self, connector, reason, reconnecting=1) Reconnecting subclasses should call with reconnecting=1. | source code
clientConnectionMade(self, broker) | source code
__getstate__(self) Remove all of the state which is mutated by connection attempts and failures, returning just the state which describes how reconnections should be attempted. | source code
getPerspective(self, *args) | source code
startGettingPerspective(self, username, password, serviceName, perspectiveName=None, client=None) | source code
doGetPerspective(self, root) | source code
`Deferred` |
login(self, credentials, client=None) Login and get perspective from remote PB server. | source code
startLogin(self, credentials, client=None) | source code
doLogin(self, root) | source code
gotPerspective(self, perspective) The remote avatar or perspective (obtained each time this factory connects) is now available. | source code
gotRootObject(self, root) The remote root object (obtained each time this factory connects) is now available. | source code
failedToGetPerspective(self, why) The login process failed, most likely because of an authorization failure (bad password), but it is also possible that we lost the new connection before we managed to send our credentials. | source code
Inherited from `twisted.spread.pb.PBClientFactory`: `buildProtocol`, `disconnect`, `getRootObject` Inherited from `twisted.spread.pb.PBClientFactory` (private): `_cbLoginAnonymous`, `_cbResponse`, `_cbSendUsername`, `_failAll`, `_reset` Inherited from `twisted.internet.protocol.ClientFactory`: `startedConnecting` Inherited from `twisted.internet.protocol.Factory`: `doStart`, `doStop`, `startFactory`, `stopFactory` Inherited from `twisted.internet.protocol.ReconnectingClientFactory`: `resetDelay`, `retry`, `stopTrying`

Class Variables | [hide private]
| __pychecker__ = `'no-override'`
| maxDelay = `300` Maximum number of seconds between connection attempts.
Inherited from `twisted.spread.pb.PBClientFactory`: `unsafeTracebacks` Inherited from `twisted.internet.protocol.Factory`: `noisy`, `numPorts` Inherited from `twisted.internet.protocol.ReconnectingClientFactory`: `connector`, `continueTrying`, `delay`, `maxRetries`, `retries` Inherited from `twisted.internet.protocol.ReconnectingClientFactory` (private): `_callID`

Instance Variables | [hide private]
Inherited from `twisted.internet.protocol.ReconnectingClientFactory`: `factor`, `initialDelay`, `jitter`

Method Details | [hide private]

### __init__(self) (Constructor) | source code
Parameters: `unsafeTracebacks` - if set, tracebacks for exceptions will be sent over the wire. `security` - security options used by the broker, default to `globalSecurity`. Overrides: twisted.spread.pb.PBClientFactory.__init__ (inherited documentation)

### clientConnectionFailed(self, connector, reason) | source code
Called when a connection has failed to connect. It may be useful to call connector.connect() - this will reconnect. Overrides: twisted.internet.protocol.ReconnectingClientFactory.clientConnectionFailed

### clientConnectionLost(self, connector, reason, reconnecting=1) | source code
Reconnecting subclasses should call with reconnecting=1. Overrides: twisted.internet.protocol.ReconnectingClientFactory.clientConnectionLost

### clientConnectionMade(self, broker) | source code
Overrides: twisted.spread.pb.PBClientFactory.clientConnectionMade

### __getstate__(self) | source code
Remove all of the state which is mutated by connection attempts and failures, returning just the state which describes how reconnections should be attempted. This will make the unserialized instance behave just as this one did when it was first instantiated. Overrides: twisted.internet.protocol.ReconnectingClientFactory.__getstate__ (inherited documentation)

### login(self, credentials, client=None) | source code
Login and get perspective from remote PB server. Currently the following credentials are supported:
       L{twisted.cred.credentials.IUsernamePassword}
       L{twisted.cred.credentials.IAnonymous}
Returns: `Deferred` A `Deferred` which will be called back with a `RemoteReference` for the avatar logged in to, or which will errback if login fails. Overrides: twisted.spread.pb.PBClientFactory.login (inherited documentation)

### gotRootObject(self, root) | source code
The remote root object (obtained each time this factory connects) is now available. This method will be called each time the connection is established and the object reference is retrieved.