Package flumotion :: Package twisted :: Module flavors :: Class StateRemoteCache
[hide private]

Class StateRemoteCache

source code

twisted.spread.jelly.Unjellyable --+        
                                   |        
   twisted.spread.flavors.RemoteCopy --+    
                                       |    
  twisted.spread.jelly.Jellyable --+   |    
                                   |   |    
 twisted.spread.flavors.Serializable --+    
                                       |    
      twisted.spread.flavors.RemoteCache --+
                                           |
                                          StateRemoteCache
Known Subclasses:

I am a remote cache of a state object.

Instance Methods [hide private]
 
__init__(self) source code
 
hasKey(self, key) source code
 
keys(self) source code
 
get(self, key, otherwise=None)
Get the state cache value for the given key.
source code
 
_ensureListeners(self) source code
 
addListener(self, listener, set=None, append=None, remove=None, setitem=None, delitem=None, invalidate=None)
Adds a listener to the remote cache.
source code
 
removeListener(self, listener) source code
 
setCopyableState(self, dict)
I will be invoked with the state to copy locally.
source code
 
observe_set(self, key, value) source code
 
observe_append(self, key, value) source code
 
observe_remove(self, key, value) source code
 
observe_setitem(self, key, subkey, value) source code
 
observe_delitem(self, key, subkey, value) source code
 
invalidate(self)
Invalidate this StateRemoteCache.
source code

Inherited from twisted.spread.flavors.RemoteCache: __cmp__, __del__, __hash__, jellyFor, remoteMessageReceived, unjellyFor

Inherited from twisted.spread.jelly.Unjellyable: __providedBy__, setStateFor

Inherited from twisted.spread.flavors.Serializable: processUniqueID

Inherited from twisted.spread.jelly.Jellyable: getStateFor

Class Variables [hide private]

Inherited from twisted.spread.flavors.RemoteCache: broker, luid

Inherited from twisted.spread.flavors.RemoteCopy: __implemented__, __provides__

Method Details [hide private]

get(self, key, otherwise=None)

source code 

Get the state cache value for the given key.

Return otherwise in case where key is present but value None.

addListener(self, listener, set=None, append=None, remove=None, setitem=None, delitem=None, invalidate=None)

source code 

Adds a listener to the remote cache.

The caller will be notified of state events via the functions given as the 'set', 'append', and 'remove', 'setitem', and 'delitem' keyword arguments.

Setting one of the event handlers to None will ignore that event. It is an error for all event handlers to be None.

Parameters:
  • listener (object implementing flumotion.twisted.flavors.IStateListener) - A new listener object that wants to receive cache state change notifications.
  • set (procedure(object, key, value) -> None) - A procedure to call when a value is set
  • append (procedure(object, key, value) -> None) - A procedure to call when a value is appended to a list
  • remove (procedure(object, key, value) -> None) - A procedure to call when a value is removed from a list
  • setitem (procedure(object, key, subkey, value) -> None) - A procedure to call when a value is set in a dict.
  • delitem (procedure(object, key, subkey, value) -> None) - A procedure to call when a value is removed from a dict.
  • invalidate (procedure(object) -> None) - A procedure to call when this cache has been invalidated.

setCopyableState(self, dict)

source code 

I will be invoked with the state to copy locally.

'state' is the data returned from the remote object's 'getStateToCopyFor' method, which will often be the remote object's dictionary (or a filtered approximation of it depending on my peer's perspective).

Overrides: twisted.spread.flavors.RemoteCopy.setCopyableState
(inherited documentation)

invalidate(self)

source code 

Invalidate this StateRemoteCache.

Calling this method will result in the invalidate callback being called for all listeners that passed an invalidate handler to addListener. This method is not called automatically; it is provided as a convenience to applications.