basicproperty.standard.dictionaryproperty
index
p:\properties\basicproperty\standard\dictionaryproperty.py

 
Modules
       
basicproperty.basic
basictypes.boundary
basictypes.latebind
weakref

 
Classes
       
BasicProperty(Propertied)
UncoercedDictionaryProperty
DictionaryProperty
WeakKeyDictionaryProperty
WeakValueDictionaryProperty

 
class DictionaryProperty(UncoercedDictionaryProperty)
    Dictionary property object, with type checking and basic coercion
 
 
Method resolution order:
DictionaryProperty
UncoercedDictionaryProperty
BasicProperty
Propertied
object

Methods defined here:
coerce(self, client, value)
Coerce the value to/from dictionary value

Methods inherited from UncoercedDictionaryProperty:
default(self, property, client)

Data and other attributes inherited from UncoercedDictionaryProperty:
bounds = [<TypeBoundary: type=<type 'dict'>>]
dataType = 'dict'

Methods inherited from BasicProperty:
__delete__(self, client)
Delete the current value of the property for the client
 
At the moment, this method does nothing beyond calling
_delValue( client ), as there does not appear to be
any common feature required from __delete__.  The method is
here primarily to maintain the consistency of the interface
and allow for applications to override _delValue without
worrying about losing future features added to __delete__.
__get__(self, client, klass=None)
Retrieve the current value of the property for the client
 
This function provides the machinery for default value and
default function support.  If the _getValue method raises
a KeyError or AttributeError, this method will attempt to
find a default value for the property using self.getDefault
__init__(self, name, documentation='', **namedarguments)
Create a new basic property object
 
name -- name of the property, used for storage and reporting
documentation -- appears in automated documentation systems
 
baseType -- an object representing the base-type of the
        property's values.  May include the following values:
 
                coerce( value ) -- coerce value to acceptable type
                check( value ) -- check that given value is acceptable,
                        return false if it is not.
                factories( ) -- return a list of factory functions/classes
                        for creating new instances of the class
                dataType -- string specifying a data-type key for the
                        values.  This specifier is entirely local to the
                        properties system, with no neccessary relation to
                        class or type names.  With that said, generally the
                        values are the dotted-name of the class/type allowed
                        for the property.
                        
                        Note: This can be a dotted name with the trailing
                        items specifying more specific data types, so, for
                        instance, str.long will use the "long string" editor if
                        it's registered, or the "string" editor if not.
                        
        if coerce is not present, the class should have an initialiser
        that allows passing a single value as the value to coerce.
 
        if check is not present, check will be done as
        isinstance( value, baseType).
 
        if factories is not present, factories will be assumed to be
        the baseType itself.
 
defaultValue -- static value to be used as default, if not
        specified, not provided
defaultFunction -- function with signature function( property,
        client ) which returns a dynamic default value
setDefaultOnGet -- if true (default), then retrieving a
        default value causes the value to be explicitly set as the
        current value
 
 
friendlyName -- user-friendly name for use in UIs and the like,
        defaults to the current value of name
trueProperty -- if true, this property really does describe a
        property, that is, a descriptor for an attribute which is
        accessed using object.x notation.
        
        if false, this property is used to interact with the
        property system, but is not actually a property of an
        object (for instance when the object is an old-style class
        which cannot support properties, you can define virtual
        properties for use with the class)  The property system
        can examine the value of trueProperty to determine whether
        to use setattr(object,name,value) or call
        property.__set__(object, value) to use the property.
 
Notes:
        You can specify _any_ name=value set to store a value, so,
        for instance, you could specify __get__ to override the
        __get__ method, or similarly _getValue or getDefault.
 
        Sub-classes may (and do) define extra name=value pairs to
        support extended functionality.  You will need to look at
        the sub-class's documentation for details on other
        significant attribute names.
__repr__(self)
Get a representation of this property object
__set__(self, client, value)
Set the current value of the property for the client
 
This function provides the machinery for coercion and
bounds checking.  Before calling the _setValue method,
__set__ calls coerce( client, value ), with the return
value from the coercion becoming the value to be set.
Coercion may raise TypeError or ValueError exceptions,
and the application should be ready to catch these errors.
 
Once coercion is finished, __set__ calls
check( client, value ) to allow each boundary
condition to check the current value.  The boundary
conditions may raise BoundaryErrors (with the particular
error classes generally being sub-classes of ValueError
or TypeError).
__str__ = __repr__(self)
Get a representation of this property object
check(self, client, value)
Use our basetype to check the coerced value's type
getBaseType(self)
Get our base-type object or None if not set
getDataType(self)
Get our data-type string
getDefault(self, client)
Get the default value of this property for the given client
 
This simply calls the Default object registered as self.default,
which, depending on whether defaultValue or defaultFunction was
specified during initialisation, will return a value or the
result of a function call.  If neither was specified, an
AttributeError will be raised.
getFactories(self)
Attempt to determine the factory callables for this property
getState(self, client)
Helper for client.__getstate__, gets storable value for this property
setState(self, client, value)
Helper for client.__setstate__, sets storable value

Data and other attributes inherited from BasicProperty:
baseType = None
setDefaultOnGet = 1
trueProperty = 1

Methods inherited from Propertied:
clone(self, **newValues)
Clone this object, with optional new property values
 
This method calls the __init__ method of your class with
the current property values of your class.  Providing newValues
(a dictionary) overrides property settings with new values.
getCloneProperties(self)
Get properties dictionary (key:value) for use in cloning of the instance
 
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
toString(self, indentation='', alreadyDone=None, indentString=' ')
Get a nicely formatted representation of this object
 
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
 
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
 
XXX Needs a far better API, likely a stand-alone class
        without the automatic inheritance problems here :(

Class methods inherited from Propertied:
getProperties(cls) from type
Get the BasicProperty properties for a particular object's class

Data and other attributes inherited from Propertied:
__dict__ = <dictproxy object at 0x0289CFF0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Propertied' objects>
list of weak references to the object (if defined)

 
class UncoercedDictionaryProperty(BasicProperty)
    Dictionary property object, with type checking
 
 
Method resolution order:
UncoercedDictionaryProperty
BasicProperty
Propertied
object

Methods defined here:
default(self, property, client)

Data and other attributes defined here:
bounds = [<TypeBoundary: type=<type 'dict'>>]
dataType = 'dict'

Methods inherited from BasicProperty:
__delete__(self, client)
Delete the current value of the property for the client
 
At the moment, this method does nothing beyond calling
_delValue( client ), as there does not appear to be
any common feature required from __delete__.  The method is
here primarily to maintain the consistency of the interface
and allow for applications to override _delValue without
worrying about losing future features added to __delete__.
__get__(self, client, klass=None)
Retrieve the current value of the property for the client
 
This function provides the machinery for default value and
default function support.  If the _getValue method raises
a KeyError or AttributeError, this method will attempt to
find a default value for the property using self.getDefault
__init__(self, name, documentation='', **namedarguments)
Create a new basic property object
 
name -- name of the property, used for storage and reporting
documentation -- appears in automated documentation systems
 
baseType -- an object representing the base-type of the
        property's values.  May include the following values:
 
                coerce( value ) -- coerce value to acceptable type
                check( value ) -- check that given value is acceptable,
                        return false if it is not.
                factories( ) -- return a list of factory functions/classes
                        for creating new instances of the class
                dataType -- string specifying a data-type key for the
                        values.  This specifier is entirely local to the
                        properties system, with no neccessary relation to
                        class or type names.  With that said, generally the
                        values are the dotted-name of the class/type allowed
                        for the property.
                        
                        Note: This can be a dotted name with the trailing
                        items specifying more specific data types, so, for
                        instance, str.long will use the "long string" editor if
                        it's registered, or the "string" editor if not.
                        
        if coerce is not present, the class should have an initialiser
        that allows passing a single value as the value to coerce.
 
        if check is not present, check will be done as
        isinstance( value, baseType).
 
        if factories is not present, factories will be assumed to be
        the baseType itself.
 
defaultValue -- static value to be used as default, if not
        specified, not provided
defaultFunction -- function with signature function( property,
        client ) which returns a dynamic default value
setDefaultOnGet -- if true (default), then retrieving a
        default value causes the value to be explicitly set as the
        current value
 
 
friendlyName -- user-friendly name for use in UIs and the like,
        defaults to the current value of name
trueProperty -- if true, this property really does describe a
        property, that is, a descriptor for an attribute which is
        accessed using object.x notation.
        
        if false, this property is used to interact with the
        property system, but is not actually a property of an
        object (for instance when the object is an old-style class
        which cannot support properties, you can define virtual
        properties for use with the class)  The property system
        can examine the value of trueProperty to determine whether
        to use setattr(object,name,value) or call
        property.__set__(object, value) to use the property.
 
Notes:
        You can specify _any_ name=value set to store a value, so,
        for instance, you could specify __get__ to override the
        __get__ method, or similarly _getValue or getDefault.
 
        Sub-classes may (and do) define extra name=value pairs to
        support extended functionality.  You will need to look at
        the sub-class's documentation for details on other
        significant attribute names.
__repr__(self)
Get a representation of this property object
__set__(self, client, value)
Set the current value of the property for the client
 
This function provides the machinery for coercion and
bounds checking.  Before calling the _setValue method,
__set__ calls coerce( client, value ), with the return
value from the coercion becoming the value to be set.
Coercion may raise TypeError or ValueError exceptions,
and the application should be ready to catch these errors.
 
Once coercion is finished, __set__ calls
check( client, value ) to allow each boundary
condition to check the current value.  The boundary
conditions may raise BoundaryErrors (with the particular
error classes generally being sub-classes of ValueError
or TypeError).
__str__ = __repr__(self)
Get a representation of this property object
check(self, client, value)
Use our basetype to check the coerced value's type
coerce(self, client, value)
Attempt to convert the given value to an appropriate data type
 
Tries to use the baseType's coerce function,
failing that, calls the base type with the
value as the first positional parameter.
getBaseType(self)
Get our base-type object or None if not set
getDataType(self)
Get our data-type string
getDefault(self, client)
Get the default value of this property for the given client
 
This simply calls the Default object registered as self.default,
which, depending on whether defaultValue or defaultFunction was
specified during initialisation, will return a value or the
result of a function call.  If neither was specified, an
AttributeError will be raised.
getFactories(self)
Attempt to determine the factory callables for this property
getState(self, client)
Helper for client.__getstate__, gets storable value for this property
setState(self, client, value)
Helper for client.__setstate__, sets storable value

Data and other attributes inherited from BasicProperty:
baseType = None
setDefaultOnGet = 1
trueProperty = 1

Methods inherited from Propertied:
clone(self, **newValues)
Clone this object, with optional new property values
 
This method calls the __init__ method of your class with
the current property values of your class.  Providing newValues
(a dictionary) overrides property settings with new values.
getCloneProperties(self)
Get properties dictionary (key:value) for use in cloning of the instance
 
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
toString(self, indentation='', alreadyDone=None, indentString=' ')
Get a nicely formatted representation of this object
 
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
 
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
 
XXX Needs a far better API, likely a stand-alone class
        without the automatic inheritance problems here :(

Class methods inherited from Propertied:
getProperties(cls) from type
Get the BasicProperty properties for a particular object's class

Data and other attributes inherited from Propertied:
__dict__ = <dictproxy object at 0x0289CA50>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Propertied' objects>
list of weak references to the object (if defined)

 
class WeakKeyDictionaryProperty(DictionaryProperty)
    Weak-Key dictionary property object
 
 
Method resolution order:
WeakKeyDictionaryProperty
DictionaryProperty
UncoercedDictionaryProperty
BasicProperty
Propertied
object

Methods defined here:
coerce(self, client, value)
Ensure that value is a weak-key dictionary
 
If the value is not already a dictionary or
WeakKeyDictionary, will go through DictionaryProperty's
coercion mechanism first.

Data and other attributes defined here:
bounds = [<TypeBoundary: type=weakref.WeakKeyDictionary>]
dataType = 'dict.weakkey'

Methods inherited from UncoercedDictionaryProperty:
default(self, property, client)

Methods inherited from BasicProperty:
__delete__(self, client)
Delete the current value of the property for the client
 
At the moment, this method does nothing beyond calling
_delValue( client ), as there does not appear to be
any common feature required from __delete__.  The method is
here primarily to maintain the consistency of the interface
and allow for applications to override _delValue without
worrying about losing future features added to __delete__.
__get__(self, client, klass=None)
Retrieve the current value of the property for the client
 
This function provides the machinery for default value and
default function support.  If the _getValue method raises
a KeyError or AttributeError, this method will attempt to
find a default value for the property using self.getDefault
__init__(self, name, documentation='', **namedarguments)
Create a new basic property object
 
name -- name of the property, used for storage and reporting
documentation -- appears in automated documentation systems
 
baseType -- an object representing the base-type of the
        property's values.  May include the following values:
 
                coerce( value ) -- coerce value to acceptable type
                check( value ) -- check that given value is acceptable,
                        return false if it is not.
                factories( ) -- return a list of factory functions/classes
                        for creating new instances of the class
                dataType -- string specifying a data-type key for the
                        values.  This specifier is entirely local to the
                        properties system, with no neccessary relation to
                        class or type names.  With that said, generally the
                        values are the dotted-name of the class/type allowed
                        for the property.
                        
                        Note: This can be a dotted name with the trailing
                        items specifying more specific data types, so, for
                        instance, str.long will use the "long string" editor if
                        it's registered, or the "string" editor if not.
                        
        if coerce is not present, the class should have an initialiser
        that allows passing a single value as the value to coerce.
 
        if check is not present, check will be done as
        isinstance( value, baseType).
 
        if factories is not present, factories will be assumed to be
        the baseType itself.
 
defaultValue -- static value to be used as default, if not
        specified, not provided
defaultFunction -- function with signature function( property,
        client ) which returns a dynamic default value
setDefaultOnGet -- if true (default), then retrieving a
        default value causes the value to be explicitly set as the
        current value
 
 
friendlyName -- user-friendly name for use in UIs and the like,
        defaults to the current value of name
trueProperty -- if true, this property really does describe a
        property, that is, a descriptor for an attribute which is
        accessed using object.x notation.
        
        if false, this property is used to interact with the
        property system, but is not actually a property of an
        object (for instance when the object is an old-style class
        which cannot support properties, you can define virtual
        properties for use with the class)  The property system
        can examine the value of trueProperty to determine whether
        to use setattr(object,name,value) or call
        property.__set__(object, value) to use the property.
 
Notes:
        You can specify _any_ name=value set to store a value, so,
        for instance, you could specify __get__ to override the
        __get__ method, or similarly _getValue or getDefault.
 
        Sub-classes may (and do) define extra name=value pairs to
        support extended functionality.  You will need to look at
        the sub-class's documentation for details on other
        significant attribute names.
__repr__(self)
Get a representation of this property object
__set__(self, client, value)
Set the current value of the property for the client
 
This function provides the machinery for coercion and
bounds checking.  Before calling the _setValue method,
__set__ calls coerce( client, value ), with the return
value from the coercion becoming the value to be set.
Coercion may raise TypeError or ValueError exceptions,
and the application should be ready to catch these errors.
 
Once coercion is finished, __set__ calls
check( client, value ) to allow each boundary
condition to check the current value.  The boundary
conditions may raise BoundaryErrors (with the particular
error classes generally being sub-classes of ValueError
or TypeError).
__str__ = __repr__(self)
Get a representation of this property object
check(self, client, value)
Use our basetype to check the coerced value's type
getBaseType(self)
Get our base-type object or None if not set
getDataType(self)
Get our data-type string
getDefault(self, client)
Get the default value of this property for the given client
 
This simply calls the Default object registered as self.default,
which, depending on whether defaultValue or defaultFunction was
specified during initialisation, will return a value or the
result of a function call.  If neither was specified, an
AttributeError will be raised.
getFactories(self)
Attempt to determine the factory callables for this property
getState(self, client)
Helper for client.__getstate__, gets storable value for this property
setState(self, client, value)
Helper for client.__setstate__, sets storable value

Data and other attributes inherited from BasicProperty:
baseType = None
setDefaultOnGet = 1
trueProperty = 1

Methods inherited from Propertied:
clone(self, **newValues)
Clone this object, with optional new property values
 
This method calls the __init__ method of your class with
the current property values of your class.  Providing newValues
(a dictionary) overrides property settings with new values.
getCloneProperties(self)
Get properties dictionary (key:value) for use in cloning of the instance
 
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
toString(self, indentation='', alreadyDone=None, indentString=' ')
Get a nicely formatted representation of this object
 
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
 
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
 
XXX Needs a far better API, likely a stand-alone class
        without the automatic inheritance problems here :(

Class methods inherited from Propertied:
getProperties(cls) from type
Get the BasicProperty properties for a particular object's class

Data and other attributes inherited from Propertied:
__dict__ = <dictproxy object at 0x0289C6B0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Propertied' objects>
list of weak references to the object (if defined)

 
class WeakValueDictionaryProperty(DictionaryProperty)
    Weak-Value dictionary property object
 
 
Method resolution order:
WeakValueDictionaryProperty
DictionaryProperty
UncoercedDictionaryProperty
BasicProperty
Propertied
object

Methods defined here:
coerce(self, client, value)
Ensure that value is a weak-value dictionary
 
If the value is not already a dictionary or
WeakKeyDictionary, will go through DictionaryProperty's
coercion mechanism first.

Data and other attributes defined here:
bounds = [<TypeBoundary: type=weakref.WeakValueDictionary>]
dataType = 'dict.weakvalue'

Methods inherited from UncoercedDictionaryProperty:
default(self, property, client)

Methods inherited from BasicProperty:
__delete__(self, client)
Delete the current value of the property for the client
 
At the moment, this method does nothing beyond calling
_delValue( client ), as there does not appear to be
any common feature required from __delete__.  The method is
here primarily to maintain the consistency of the interface
and allow for applications to override _delValue without
worrying about losing future features added to __delete__.
__get__(self, client, klass=None)
Retrieve the current value of the property for the client
 
This function provides the machinery for default value and
default function support.  If the _getValue method raises
a KeyError or AttributeError, this method will attempt to
find a default value for the property using self.getDefault
__init__(self, name, documentation='', **namedarguments)
Create a new basic property object
 
name -- name of the property, used for storage and reporting
documentation -- appears in automated documentation systems
 
baseType -- an object representing the base-type of the
        property's values.  May include the following values:
 
                coerce( value ) -- coerce value to acceptable type
                check( value ) -- check that given value is acceptable,
                        return false if it is not.
                factories( ) -- return a list of factory functions/classes
                        for creating new instances of the class
                dataType -- string specifying a data-type key for the
                        values.  This specifier is entirely local to the
                        properties system, with no neccessary relation to
                        class or type names.  With that said, generally the
                        values are the dotted-name of the class/type allowed
                        for the property.
                        
                        Note: This can be a dotted name with the trailing
                        items specifying more specific data types, so, for
                        instance, str.long will use the "long string" editor if
                        it's registered, or the "string" editor if not.
                        
        if coerce is not present, the class should have an initialiser
        that allows passing a single value as the value to coerce.
 
        if check is not present, check will be done as
        isinstance( value, baseType).
 
        if factories is not present, factories will be assumed to be
        the baseType itself.
 
defaultValue -- static value to be used as default, if not
        specified, not provided
defaultFunction -- function with signature function( property,
        client ) which returns a dynamic default value
setDefaultOnGet -- if true (default), then retrieving a
        default value causes the value to be explicitly set as the
        current value
 
 
friendlyName -- user-friendly name for use in UIs and the like,
        defaults to the current value of name
trueProperty -- if true, this property really does describe a
        property, that is, a descriptor for an attribute which is
        accessed using object.x notation.
        
        if false, this property is used to interact with the
        property system, but is not actually a property of an
        object (for instance when the object is an old-style class
        which cannot support properties, you can define virtual
        properties for use with the class)  The property system
        can examine the value of trueProperty to determine whether
        to use setattr(object,name,value) or call
        property.__set__(object, value) to use the property.
 
Notes:
        You can specify _any_ name=value set to store a value, so,
        for instance, you could specify __get__ to override the
        __get__ method, or similarly _getValue or getDefault.
 
        Sub-classes may (and do) define extra name=value pairs to
        support extended functionality.  You will need to look at
        the sub-class's documentation for details on other
        significant attribute names.
__repr__(self)
Get a representation of this property object
__set__(self, client, value)
Set the current value of the property for the client
 
This function provides the machinery for coercion and
bounds checking.  Before calling the _setValue method,
__set__ calls coerce( client, value ), with the return
value from the coercion becoming the value to be set.
Coercion may raise TypeError or ValueError exceptions,
and the application should be ready to catch these errors.
 
Once coercion is finished, __set__ calls
check( client, value ) to allow each boundary
condition to check the current value.  The boundary
conditions may raise BoundaryErrors (with the particular
error classes generally being sub-classes of ValueError
or TypeError).
__str__ = __repr__(self)
Get a representation of this property object
check(self, client, value)
Use our basetype to check the coerced value's type
getBaseType(self)
Get our base-type object or None if not set
getDataType(self)
Get our data-type string
getDefault(self, client)
Get the default value of this property for the given client
 
This simply calls the Default object registered as self.default,
which, depending on whether defaultValue or defaultFunction was
specified during initialisation, will return a value or the
result of a function call.  If neither was specified, an
AttributeError will be raised.
getFactories(self)
Attempt to determine the factory callables for this property
getState(self, client)
Helper for client.__getstate__, gets storable value for this property
setState(self, client, value)
Helper for client.__setstate__, sets storable value

Data and other attributes inherited from BasicProperty:
baseType = None
setDefaultOnGet = 1
trueProperty = 1

Methods inherited from Propertied:
clone(self, **newValues)
Clone this object, with optional new property values
 
This method calls the __init__ method of your class with
the current property values of your class.  Providing newValues
(a dictionary) overrides property settings with new values.
getCloneProperties(self)
Get properties dictionary (key:value) for use in cloning of the instance
 
By default you get getProperties()' values, with an
attempt made to use the property's name, then the property's
direct "__get__" method.
toString(self, indentation='', alreadyDone=None, indentString=' ')
Get a nicely formatted representation of this object
 
This version assumes that getProperties returns
the list of properties which should be presented,
it recursively calls it's children with greater
indents to get their representations.
 
indentation -- current string indentation level
alreadyDone -- set of object ids which are already finished
 
XXX Needs a far better API, likely a stand-alone class
        without the automatic inheritance problems here :(

Class methods inherited from Propertied:
getProperties(cls) from type
Get the BasicProperty properties for a particular object's class

Data and other attributes inherited from Propertied:
__dict__ = <dictproxy object at 0x0289CFF0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Propertied' objects>
list of weak references to the object (if defined)