twisted :: spread :: pb :: Broker :: Class Broker
[hide private]

classobj Broker

internet.protocol.BaseProtocol --+        
                                 |        
        internet.protocol.Protocol --+    
                                     |    
        persisted.styles.Ephemeral --+    
                                     |    
                         banana.Banana --+
                                         |
                                        Broker
Known Subclasses:

I am a broker for objects.

Instance Methods [hide private]
 
__init__(self, isClient=1, security=<twisted.spread.jelly.SecurityOptions instance at 0x7f9a03d6f320>)
 
_recvMessage(self, findObjMethod, requestID, objectID, message, answerRequired, netArgs, netKw)
Received a message-send.
 
_sendAnswer(self, netResult, requestID)
(internal) Send an answer to a previously sent message.
 
_sendError(self, fail, requestID)
(internal) Send an error for a previously sent message.
 
_sendFailure(self, fail, requestID)
Log error and then send it.
 
_sendFailureOrError(self, fail, requestID)
Call _sendError or _sendFailure, depending on whether fail represents an Error subclass or not.
 
_sendMessage(self, prefix, perspective, objectID, message, args, kw)
 
cacheLocally(self, cid, instance)
(internal)
 
cacheRemotely(self, instance)
XXX
 
cachedLocallyAs(self, cid)
 
cachedRemotelyAs(self, instance, incref=0)
Returns: An ID that says what this instance is cached as remotely, or None if it's not.
 
connectionFailed(self)
 
connectionLost(self, reason)
The connection was lost.
 
connectionReady(self)
Initialize.
 
decCacheRef(self, objectID)
(internal) Send a DECACHE directive.
 
dontNotifyOnDisconnect(self, notifier)
 
expressionReceived(self, sexp)
Evaluate an expression as it's received.
 
localObjectForID(self, luid)
Get a local object for a locally unique ID.
 
newLocalID(self)
Returns: A newly generated LUID.
 
newRequestID(self)
Returns: A newly generated request ID.
 
notifyOnConnect(self, notifier)
 
notifyOnDisconnect(self, notifier)
 
notifyOnFail(self, notifier)
 
pauseProducing(self)
 
proto_answer(self, requestID, netResult)
(internal) Got an answer to a previously sent message.
 
proto_cachemessage(self, requestID, objectID, message, answerRequired, netArgs, netKw)
 
proto_decache(self, objectID)
(internal) Decrement the reference count of a cached object.
 
proto_decref(self, objectID)
(internal) Decrement the reference count of an object.
 
proto_didNotUnderstand(self, command)
Respond to stock 'didNotUnderstand' message.
 
proto_error(self, requestID, fail)
(internal) Deal with an error.
 
proto_message(self, requestID, objectID, message, answerRequired, netArgs, netKw)
 
proto_uncache(self, objectID)
(internal) Tell the client it is now OK to uncache an object.
 
proto_version(self, vnum)
Protocol message: (version version-number)
 
registerPageProducer(self, pager)
 
registerReference(self, object)
Store a persistent reference to a local object and map its id() to a generated, session-unique ID.
 
remoteForName(self, name)
Returns an object from the remote name mapping.
 
remotelyCachedForLUID(self, luid)
Returns: An instance which is cached remotely.
 
resumeProducing(self)
Called when the consumer attached to me runs out of buffer.
 
sendCall(self, *exp)
Utility method to send an expression to the other side of the connection.
 
sendDecRef(self, objectID)
(internal) Send a DECREF directive.
 
serialize(self, object, perspective=None, method=None, args=None, kw=None)
Jelly an object according to the remote security rules for this broker.
 
setNameForLocal(self, name, object)
Store a special (string) ID for this object.
 
stopProducing(self)
 
unserialize(self, sexp, perspective=None)
Unjelly an sexp according to the local security rules for this broker.

Inherited from banana.Banana: callExpressionReceived, connectionMade, dataReceived, gotItem, sendEncoded, setPrefixLimit

Inherited from banana.Banana (private): _encode, _selectDialect

Inherited from internet.protocol.Protocol: __provides__, logPrefix

Inherited from internet.protocol.BaseProtocol: __providedBy__, makeConnection

Inherited from persisted.styles.Ephemeral: __getstate__, __reduce__, __setstate__

Class Variables [hide private]
  factory = None
  maxBrokerRefsViolations = 0
  username = None
  version = 6
  waitingForAnswers = None

Inherited from banana.Banana: buffer, incomingVocabulary, k, outgoingVocabulary, prefixLimit, sizeLimit, v

Inherited from internet.protocol.Protocol: __implemented__

Inherited from internet.protocol.BaseProtocol: connected, transport

Instance Variables [hide private]

Inherited from banana.Banana: knownDialects

Method Details [hide private]

__init__(self, isClient=1, security=<twisted.spread.jelly.SecurityOptions instance at 0x7f9a03d6f320>)
(Constructor)

 
Overrides: banana.Banana.__init__

_recvMessage(self, findObjMethod, requestID, objectID, message, answerRequired, netArgs, netKw)

 

Received a message-send.

Look up message based on object, unserialize the arguments, and invoke it with args, and send an 'answer' or 'error' response.

Parameters:
  • findObjMethod - A callable which takes objectID as argument.
  • requestID - The requiest ID.
  • objectID - The object ID.
  • message - The message.
  • answerRequired
  • netArgs - Arguments.
  • netKw - Keyword arguments.

_sendAnswer(self, netResult, requestID)

 

(internal) Send an answer to a previously sent message.

Parameters:
  • netResult - The answer.
  • requestID - The request ID.

_sendError(self, fail, requestID)

 

(internal) Send an error for a previously sent message.

Parameters:
  • fail - The failure.
  • requestID - The request ID.

_sendFailure(self, fail, requestID)

 

Log error and then send it.

Parameters:
  • fail - The failure.
  • requestID - The request ID.

_sendFailureOrError(self, fail, requestID)

 

Call _sendError or _sendFailure, depending on whether fail represents an Error subclass or not.

Parameters:
  • fail - The failure.
  • requestID - The request ID.

cacheLocally(self, cid, instance)

 

(internal)

Store a non-filled-out cached instance locally.

cacheRemotely(self, instance)

 

XXX

Returns:
A new LUID.

cachedRemotelyAs(self, instance, incref=0)

 
Parameters:
  • instance - The instance to look up.
  • incref - Flag to specify whether to increment the reference.
Returns:
An ID that says what this instance is cached as remotely, or None if it's not.

connectionLost(self, reason)

 

The connection was lost.

Parameters:
  • reason - message to put in failure.Failure
Overrides: internet.protocol.Protocol.connectionLost

connectionReady(self)

 

Initialize. Called after Banana negotiation is done.

Overrides: banana.Banana.connectionReady

decCacheRef(self, objectID)

 

(internal) Send a DECACHE directive.

Parameters:
  • objectID - The object ID.

dontNotifyOnDisconnect(self, notifier)

 
Parameters:
  • notifier - callback to remove from list of disconnect callbacks.

expressionReceived(self, sexp)

 

Evaluate an expression as it's received.

Overrides: banana.Banana.expressionReceived

localObjectForID(self, luid)

 

Get a local object for a locally unique ID.

Returns:
An object previously stored with registerReference or None if there is no object which corresponds to the given identifier.

newLocalID(self)

 
Returns:
A newly generated LUID.

newRequestID(self)

 
Returns:
A newly generated request ID.

notifyOnConnect(self, notifier)

 
Parameters:
  • notifier - callback to call when the Broker connects.

notifyOnDisconnect(self, notifier)

 
Parameters:
  • notifier - callback to call when the Broker disconnects.

notifyOnFail(self, notifier)

 
Parameters:
  • notifier - callback to call if the Broker fails to connect.

proto_answer(self, requestID, netResult)

 

(internal) Got an answer to a previously sent message.

Look up the appropriate callback and call it.

Parameters:
  • requestID - The request ID.
  • netResult - The answer.

proto_decache(self, objectID)

 

(internal) Decrement the reference count of a cached object.

If the reference count is zero, free the reference, then send an 'uncached' directive.

Parameters:
  • objectID - The object ID.

proto_decref(self, objectID)

 

(internal) Decrement the reference count of an object.

If the reference count is zero, it will free the reference to this object.

Parameters:
  • objectID - The object ID.

proto_didNotUnderstand(self, command)

 

Respond to stock 'didNotUnderstand' message.

Log the command that was not understood and continue. (Note: this will probably be changed to close the connection or raise an exception in the future.)

Parameters:
  • command - The command to log.

proto_error(self, requestID, fail)

 

(internal) Deal with an error.

Parameters:
  • requestID - The request ID.
  • fail - The failure.

proto_uncache(self, objectID)

 

(internal) Tell the client it is now OK to uncache an object.

Parameters:
  • objectID - The object ID.

proto_version(self, vnum)

 

Protocol message: (version version-number)

Check to make sure that both ends of the protocol are speaking the same version dialect.

Parameters:
  • vnum - The version number.

registerReference(self, object)

 

Store a persistent reference to a local object and map its id() to a generated, session-unique ID.

Parameters:
  • object - a local object
Returns:
the generated ID

remoteForName(self, name)

 

Returns an object from the remote name mapping.

Note that this does not check the validity of the name, only creates a translucent reference for it.

Parameters:
  • name - The name to look up.
Returns:
An object which maps to the name.

remotelyCachedForLUID(self, luid)

 
Parameters:
  • luid - The LUID to look up.
Returns:
An instance which is cached remotely.

sendCall(self, *exp)

 

Utility method to send an expression to the other side of the connection.

Parameters:
  • exp - The expression.

sendDecRef(self, objectID)

 

(internal) Send a DECREF directive.

Parameters:
  • objectID - The object ID.

serialize(self, object, perspective=None, method=None, args=None, kw=None)

 

Jelly an object according to the remote security rules for this broker.

Parameters:
  • object - The object to jelly.
  • perspective - The perspective.
  • method - The method.
  • args - Arguments.
  • kw - Keyword arguments.

setNameForLocal(self, name, object)

 

Store a special (string) ID for this object.

This is how you specify a 'base' set of objects that the remote protocol can connect to.

Parameters:
  • name - An ID.
  • object - The object.

unserialize(self, sexp, perspective=None)

 

Unjelly an sexp according to the local security rules for this broker.

Parameters:
  • sexp - The object to unjelly.
  • perspective - The perspective.