basictypes.boundary
index
p:\properties\basictypes\boundary.py

Boundary objects for checking data values
 
(following paragraph is obsolete, feel free to use
the boundaries, but that's not a "should" requirement).
 
        Boundaries should be used for all type and value checking
        within the basicproperty package.  When defining your own
        boundary objects, derive from Boundary, providing a __call__
        method of the appropriate signature, and raising
        BoundaryErrors to indicate out of bounds values.

 
Modules
       
basictypes.latebind

 
Classes
       
BoundaryError
BoundaryTypeError(BoundaryError, TypeError)
BoundaryValueError(BoundaryError, ValueError)
object
Boundary
ForEachBoundary
LengthBoundary
NonNullBoundary
RangeBoundary
TypeBoundary

 
class Boundary(object)
    Base class from which boundary conditions should be derived
 
  Methods defined here:
__call__(self, property, client, value)
Check value against boundary conditions
 
Your boundary should override this method, check the value
and raise appropriate BoundaryError's if the value is
outside of bounds

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

 
class BoundaryError
    Base class for all Boundary exceptions
 
This class keeps references to the objects involved in the
transgression of the boundary.  This allows for higher level
systems (such as a GUI application) to provide interactive
support for fixing the boundary transgression.
 
  Methods defined here:
__init__(self, property, boundary, client, value, message='')
Initialize the error, just stores the references to minimize overhead where the error isn't actually needed
__repr__(self)
Get a short user-friendly representation of the error
__str__(self)
Get a full user-friendly string representation of the error

Data and other attributes defined here:
index = None

 
class BoundaryTypeError(BoundaryError, TypeError)
    Boundary object which checks data type found a non-conforming value/type
 
This error is primarily raised by the TypeBoundary class.
 
It can be caught explicitly, or as a TypeError, depending
on your application's requirements.
 
 
Method resolution order:
BoundaryTypeError
BoundaryError
TypeError
StandardError
Exception

Methods inherited from BoundaryError:
__init__(self, property, boundary, client, value, message='')
Initialize the error, just stores the references to minimize overhead where the error isn't actually needed
__repr__(self)
Get a short user-friendly representation of the error
__str__(self)
Get a full user-friendly string representation of the error

Data and other attributes inherited from BoundaryError:
index = None

Methods inherited from Exception:
__getitem__(...)

 
class BoundaryValueError(BoundaryError, ValueError)
    Boundary object which checks data value found a non-conforming value
 
This error is raised by most Boundary classes.
 
It can be caught explicitly, or as a TypeError, depending
on your application's requirements.
 
 
Method resolution order:
BoundaryValueError
BoundaryError
ValueError
StandardError
Exception

Methods inherited from BoundaryError:
__init__(self, property, boundary, client, value, message='')
Initialize the error, just stores the references to minimize overhead where the error isn't actually needed
__repr__(self)
Get a short user-friendly representation of the error
__str__(self)
Get a full user-friendly string representation of the error

Data and other attributes inherited from BoundaryError:
index = None

Methods inherited from Exception:
__getitem__(...)

 
class ForEachBoundary(Boundary)
    For iterable objects, checks a given boundary for each item in object
 
The ForEachBoundary is used to apply another Boundary
object to each object in an iterable value.  This allows you
to define checks such as this:
 
        bounds = [
                TypeBoundary ( list ),
                ForEachBoundaryTypeBoundary( int )),
                ForEachBoundaryRangeBoundary( min=0, max=100 )),
        ]
 
which would require that the property value be a list of
integers from 0 to 100 (inclusive).
 
 
Method resolution order:
ForEachBoundary
Boundary
object

Methods defined here:
__call__(self, property, client, value)
Check each item in value against base boundary condition
__init__(self, base)
__repr__(self)

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

 
class LengthBoundary(Boundary)
    Restrict the length of value to between/above/below boundary minimum and/or maximum lengths
 
Conceptually, LengthBoundary is a very minor sub-class of
RangeBoundary, where the result of passing the value to
a function (in this case len) is compared with the boundary
values, rather then the initial value.  This implementation
doesn't currently take advantage of this abstraction.
 
 
Method resolution order:
LengthBoundary
Boundary
object

Methods defined here:
__call__(self, property, client, value)
Check value against boundary conditions
__init__(self, minimum=[], maximum=[])
Specify minimum and/or maximum, if one or both is left off, that bound is not checked
__repr__(self)

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

 
class NonNullBoundary(Boundary)
    Require that value evaluate to true (non-null)
 
 
Method resolution order:
NonNullBoundary
Boundary
object

Methods defined here:
__call__(self, property, client, value)
Check value against boundary conditions
__repr__(self)

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

 
class RangeBoundary(Boundary)
    Restrict the value to between/above/below boundary minimum and/or maximum values
 
The RangeBoundary allows you to constrain values based on
comparisons with minimum and/or maximum values.  The class
allows for specifying one or both of the boundary conditions.
 
Note: minimum and maximum are included in the set of valid values
 
Note: although the obvious use for RangeBoundaries is for
simple data types (integers, floats, strings), there is nothing
in the Boundary itself which restricts the use to simple data
types.  All that is required is the ability to compare instances
using the < and > operators
 
 
Method resolution order:
RangeBoundary
Boundary
object

Methods defined here:
__call__(self, property, client, value)
Check value against boundary conditions
__init__(self, minimum=[], maximum=[])
Specify minimum and/or maximum, if one or both is left off, that bound is not checked
 
Note: minimum and maximum are included in the set of valid values
(i.e. the range is inclusive of the end points)
__repr__(self)

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

 
class TypeBoundary(Boundary)
    Restrict the type of the value to a subclass of a boundary type (or types)
 
The TypeBoundary provides a way of checking that a value
is an instance of a particular type, or one of a set of
types.  Objects are within the boundary if:
        isinstance( object, boundaryTypes )
 
 
Method resolution order:
TypeBoundary
Boundary
object

Methods defined here:
__call__(self, property, client, value)
Check value against boundary conditions
__init__(self, boundaryType)
Initialize the TypeBoundary object with a boundaryType specifier
 
The boundaryType specifier can be any of the following:
 
        string -- dotted-name specifying the full class name
                (including module) for a single class/type
                for example "wxPython.wx.wxFramePtr"
 
                This specification allows for late-binding of the
                data type, which avoids mutual import problems in certain
                situations.
 
                Note: if this specification is used, the type boundary
                may raise BoundaryTypeError exceptions on the first
                __call__ of the Boundary when the attempt is made
                to import the class/type.
 
        class -- a single class/type object,
                for example str or wxPython.wx.wxFramePtr
 
        tuple -- a tuple of class/type objects,
                for example ( str, list, tuple, unicode ) or
                string specifiers (as above)
__repr__(self)
resolveBoundary(self, boundarySpecifier, property, client, value)
Resolve a particular boundary specifier into a boundary class

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

 
Data
        NULL = []