Package buildbot :: Package db :: Module state :: Class StateConnectorComponent
[frames] | no frames]

Class StateConnectorComponent

source code

               object --+    
                        |    
base.DBConnectorComponent --+
                            |
                           StateConnectorComponent

A DBConnectorComponent to handle maintaining arbitrary key/value state for Buildbot objects. Objects are identified by their (user-visible) name and their class. This allows e.g., a 'nightly_smoketest' object of class NightlyScheduler to maintain its state even if it moves between masters, but avoids cross-contaminating state between different classes.

Note that the class is not interpreted literally, and can be any string that will uniquely identify the class for the object; if classes are renamed, they can continue to use the old names.

Nested Classes
  Thunk
Instance Methods
 
getObjectId(self, name, class_name)
Get the object ID for this combination of a name and a class.
source code
 
getState(self, objectid, name, default=<class buildbot.db.state.Thunk at 0x3258d50>)
Get the state value for name for the object with id objectid.
source code
 
setState(self, objectid, name, value)
Set the state value for name for the object with id objectid, overwriting any existing value.
source code

Inherited from base.DBConnectorComponent: __init__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables

Inherited from base.DBConnectorComponent: connector

Instance Variables

Inherited from base.DBConnectorComponent: db

Properties

Inherited from object: __class__

Method Details

getObjectId(self, name, class_name)

source code 

Get the object ID for this combination of a name and a class. This will add a row to the 'objects' table if none exists already.

Parameters:
  • name - name of the object
  • class_name - object class name
Returns:
the objectid, via a Deferred.

getState(self, objectid, name, default=<class buildbot.db.state.Thunk at 0x3258d50>)

source code 

Get the state value for name for the object with id objectid.

Parameters:
  • objectid - objectid on which the state should be checked
  • name - name of the value to retrieve
  • default - (optional) value to return if name is not present
Returns:
state value via a Deferred
Raises:
  • KeyError - if name is not present and no default is given
  • TypeError - if JSON parsing fails

setState(self, objectid, name, value)

source code 

Set the state value for name for the object with id objectid, overwriting any existing value.

Parameters:
  • objectid - the objectid for which the state should be changed
  • name - the name of the value to change
  • value - the value to set - must be a JSONable object
  • returns - Deferred
Raises:
  • TypeError - if JSONification fails