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

Boundary objects for checking data values
 
You use a boundary object by passing a sequence of boundaries
in to a BasicProperty as the keyword argument "boundaries".
Boundaries must conform to the interface described by the
Boundary class, but do not necessarily need to be derived from
them.  For instance, if you would like to define boundaries
as functions or methods, feel free.
 
The Boundary will always be called with all three arguments
from BasicProperty, the allowance for property or client being
None is just a convenience if you want to re-use the boundary
checking code.
 
NOTE:
        The API for Boundary objects changed the order of the
        arguments in version 0.6.2!  If you were somehow using
        Boundary objects before this you *must* change your code
        to use the new API!

 
Modules
       
basictypes.latebind

 
Classes
       
BoundaryError
BoundaryTypeError(BoundaryError, TypeError)
BoundaryValueError(BoundaryError, ValueError)
object
Boundary
ForEach
Length
NotNull
Range
Type

 
class Boundary(object)
    Base class from which boundary conditions should be derived
 
  Methods defined here:
__call__(self, value, property=None, client=None)
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 0x01C53290>
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 ForEach(Boundary)
    For iterable objects, checks a given boundary for each item in object
 
The ForEach boundary is used to apply another Boundary
object to each object in an iterable value.  This allows you
to define checks such as this:
 
        constraints = [
                Type( list ),
                ForEachType( int )),
                ForEachRange( min=0, max=100 )),
        ]
 
which would require that the property value be a list of
integers from 0 to 100 (inclusive).
 
 
Method resolution order:
ForEach
Boundary
object

Methods defined here:
__call__(self, value, property=None, client=None)
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 0x01C533F0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Boundary' objects>
list of weak references to the object (if defined)

 
class Length(Boundary)
    Restrict the length of value to between/above/below boundary minimum and/or maximum lengths
 
Conceptually, Length boundary is a very minor sub-class of
Range, 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:
Length
Boundary
object

Methods defined here:
__call__(self, value, property=None, client=None)
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 0x01C53830>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Boundary' objects>
list of weak references to the object (if defined)

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

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

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

 
class Range(Boundary)
    Restrict the value to between/above/below boundary minimum and/or maximum values
 
The Range 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 Range boundaries 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:
Range
Boundary
object

Methods defined here:
__call__(self, value, property=None, client=None)
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 0x01C53F90>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Boundary' objects>
list of weak references to the object (if defined)

 
class Type(Boundary)
    Restrict the type of the value to a subclass of a boundary type (or types)
 
Type 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:
Type
Boundary
object

Methods defined here:
__call__(self, value, property=None, client=None)
Check value against boundary conditions
__init__(self, boundaryType)
Initialize the Type 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 0x01C533F0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Boundary' objects>
list of weak references to the object (if defined)

 
Data
        NULL = []
__file__ = r'p:\properties\basictypes\boundary.pyc'
__name__ = 'basictypes.boundary'