pdk.PropertyManagers ($Date: 2002/12/04 10:13:05 $)
index
pdk/PropertyManagers.py

Property management classes.

Properties are variables (in the sense defined in the pdk.Variables module) that are used as instance attributes. They are particularly useful for validating user input in interactive sessions.

The main property manager class PropertyManager

A good use case are device drivers, as it is demonstrated in the example code in this module. Another useful application are the classes in the pdk.Gui.Widgets.MonitoringWidgets module, which provide a set of widgets that monitor the value of a property in a bi-directional fashion (i.e., the widget value changes when the property changes and vice versa).

This code incorporates ideas taken from Graphite, which was originally written written by Joseph and Michelle Strout in 1999.

FOG 08.2001,10.2002

 
Classes
            
__builtin__.object
PropertyManager
ComponentPropertyManager
IntegratedPropertyManager
 
class ComponentPropertyManager(PropertyManager)
     
Purpose:adds handling of components to the basic PropertyManager class
Detail:

a component is an object that is accessible as an attribute of the container object. Component properties are accessed with this notation:

<component name>_<property name>

Note that you must not initialize component properties in the constructor call; rather, set up the components after the instance has been created by calling the addComponent method, and then call configure to initialize the components.


 
  
Method resolution order:
ComponentPropertyManager
PropertyManager
__builtin__.object

Methods defined here:
__init__(self, **initPropertyD)
addComponent(self, name, group, component)
configure(self, **propertyD)
getComponent(self, name, group=None)
getComponentGroup(self, group)
 
class IntegratedPropertyManager(PropertyManager)
     
Purpose:adds signalling and XML registry updating to the PropertyManager
Detail:this is implemented by overwriting the PropertyManager.configure to also emit a signal and/or register a property value change. Note that, whith this implementation, neither setting the initialization values for the properties (in the constructor) nor setting them directly (as in foo.bar = foobar) does trigger a signal or register a change. Note also that, by default, a Signal instance is created with a lambda returning the current value of the property as send function. To override this, manually call the .initializeSignal method with the signal object/send function combination of your choice (see the initializeWidget method of pdk.Gui.WidgetStateManagers._WidgetStateManager for an example).

 
  
Method resolution order:
IntegratedPropertyManager
PropertyManager
__builtin__.object

Methods defined here:
__getstate__(self)
__init__(self, objectIdString, enableSignalling=0, xmlRegistry=None)
Parameters:
  • objectIdString: unique (within the application) string representation of the object the properties of which are being managed
  • enableSignalling: specifies whether property changes should trigger a corresponding signal to be sent in this object or not
  • xmlRegistry: if passed, this has to be a pdk.DataBaseClasses.XmlReadWriteDataBase instance (i.e., a DOM tree) that can then be used to store the current property values for this object, most conveniently with the .storePropertiesToRegistry method (which will ignore read-only properties, however!). In this case, the objectIdString parameter specifies the target node in the DOM tree (as an underscore-separated path starting from the root node) that will be used to store the property data
__setstate__(self, argT)
configure(self, NOSIGNAL=0, DOREGISTER=0, **propertyD)
configureFromRegistry(self)
retrieves all persistent information for this object and calls the .configure method with it.
configureNoCallbacks(self, **propertyD)
configurePrivate(self, NOSIGNAL=0, DOREGISTER=0, **propertyD)
getId(self)
getPropertiesFromRegistry(self)
note that this removes the "id" attribute from the dictionary returned from the XML registry.
getPropertyFromRegistry(self, propertyName)
getRegistry(self)
getRegistryNode(self)
initializeSignal(self, signallingObject, propertyName, messageId, sendData=None)
registerChange(self, propertyName, propertyValue)
setRegistryNode(self, domKeyTT)
signalChange(self, propertyName, propertyValue)
storePropertiesToRegistry(self)
storePropertyToRegistry(self, propertyName)
 
class PropertyManager(__builtin__.object)
     
Purpose:class for managing properties in objects
Detail:

classes derived from PropertyManager may define new properties in a "PROPERTIES" dictionary. During instantiation, all base classes are traversed and all their property definitions are added to the definitions of the derived class. Property names are all lowercase to distinguish them from local instance variables as well as from special keywords needed for implementing the property behavior (which are all uppercase). Properties are implemented as restricted attributes using a specialized descriptor (see pdk.PropertyManagers.ManagedPropertyDescriptor). The constructor takes arbitrary initial value for the defined properties and the main method, .configure allows for simultaneous runtime configuration of multiple properties. As described in more detail in the pdk.Properties module, each property can define callbacks to be triggered upon various actions (e.g., a get callback when a property is accessed).

Misc. Notes:
  • new properties can be added at runtime with the .addProperty and .addClassProperty methods
  • calling the .configure method for a read-only attribute of non-None value will raise an error
  • if the callbacks for a property rely on the constructor having finished its work, set the AUTOINIT flag for this property to False and then call configure or setToDefaultValue explicitly
  • dynamically adding/modifying properties to/of a base class will not be reflected in derived classes, as each class collects the properties from all bases only once from the static class namespace (you can call ._updatePropertiesFromBases on derived classes to update the property dictionary)
  • property definitions in base classes can be overridden by defining a property with the same name in a derived class. Base classes are taversed in the Python-specific left-to-right manner

 
   Methods defined here:
__getstate__(self)
__init__(self, **initPropertyD)
Parameters:
  • initPropertyD: supplies initial property values. A

    ValueError is raised if any key refers to an undefined property

__setstate__(self, (propertyD, propertyValueD))
__str__(self)
addClassProperty(self, propertyName, propertyInstance)
adds a new property propertyInstance as propertyName to the class.
addProperty(self, propertyName, propertyInstance)
adds a new property propertyInstance as propertyName.
configure(self, **propertyD)
generic method for setting values for (multiple) properties.
configureNoCallbacks(self, **propertyD)
like .configure, but does not execute any callbacks.
configurePrivate(self, **propertyD)
like .configure, but by-passes the read-only check.
default(self, propertyName)
returns the default value for property propertyName.
getClassProperty(self, propertyName)
returns the class-level property propertyName.
getProperties(self, copy=1)
returns (a copy of) all properties defined for this instance.
getProperty(self, propertyName)
returns the property propertyName.
getPropertyNames(self)
returns all property names.
hasProperty(self, propertyName)
test for the presence of a property propertyName.
help(self, propertyName=None)
returns the help string for property propertyName or for all properties, if propertyName is None.
removeProperty(self, propertyName)
removes the property propertyName from this instance.
setClassDefaultValues(self, **propertyD)
set new defaults for properties of this class (and derived classes) given in **propertyD. Note that the defaults are also changed for the current instance.
setDefaultValues(self, **propertyD)
set new defaults for the properties of this instance given in propertyD. Note that, if a property is currently set to its old default value, it will automatically be set to its new default value.
setReadOnly(self, *propertyNameT)
set the properties given in %*propertyNameT% as readonly.
setToDefaultValue(self, *propertyNameT)
set the properties given in *propertyNameT to their current default values.
updateProperties(self, newPropertyD)
updates the properties of this instance with the new properties provided in propertyD. Raises a KeyError if propertyD contains an undefined property name; raises a ValueError, if any value in propertyD is not a Property instance.

Data and non-method functions defined here:
__dict__ = <dict-proxy object>
__weakref__ = <member '__weakref__' of 'PropertyManager' objects>
 
Functions
            
dir(arg=None)
augments the standard dir() function to return a list of properties for a PropertyManager instance.
help(arg, propertyName=None)
return documentation for arg.
REGISTERCONFIGURESLOT(signalObject, propertyName, slotObject, receiveFunc=None, rank=None)
Purpose:create a specialized slot for a property configuration event
UNREGISTERCONFIGURESLOT(signalObject, propertyName, slotObject)
 
Author
            
$Author: gathmann $