Type IField
Interface
--+
|
IField
- Known Subclasses:
-
IBool
,
IBytes
,
IChoice
,
IContainer
,
IDate
,
IDatetime
,
IFloat
,
IInt
,
IInterfaceField
,
IIterable
,
ILen
,
IObject
,
IOrderable
,
IText
,
ITimedelta
Basic Schema Field Interface.
Fields are used for Interface specifications. They at least provide a
title, description and a default value. You can also specify if they are
required and/or readonly.
The Field Interface is also used for validation and specifying
constraints.
We want to make it possible for a IField to not only work on its value
but also on the object this value is bound to. This enables a Field
implementation to perform validation against an object which also marks a
certain place.
Note that many fields need information about the object containing a
field. For example, when validating a value to be set as an object
attribute, it may be necessary for the field to introspect the object's
state. This means that the field needs to have access to the object when
performing validation:
bound = field.bind(object)
bound.validate(value)
Class Variable Summary |
str |
bind = "Return a copy of this field which is bound to co...
|
unicode |
constraint = u"Check a customized constraint on the valu...
|
unicode |
default = u'Default Value\n\nThe field default value may...
|
unicode |
description = u'Description\n\nA description of the fiel...
|
unicode |
missing_value = u"Missing Value\n\nIf input for this Fie...
|
unicode |
order = u'Field Order\n\n The order attribute can...
|
str |
query = "Query the value of the field for the given obje...
|
unicode |
readonly = u"Read Only\n\nIf true, the field's value can...
|
unicode |
required = u'Required\n\nTells whether a field requires ...
|
str |
set = 'Set the value of the field for the object\n\n ...
|
unicode |
title = u'Title\n\nA short summary or label'
|
unicode |
validate = u'Validate that the given value is a valid fi...
|
bind
-
- Type:
-
str
- Value:
"""Return a copy of this field which is bound to context.
The copy of the Field will have the 'context' attribute set
to 'object'. This way a Field can implement more complex
checks involving the object's location/environment.
Many fields don't need to be bound. Only fields that condition
validation or properties on an object containing the field
...
|
|
constraint
-
- Type:
-
unicode
- Value:
u"Check a customized constraint on the value.\n\n You can imple\
ment this method with your Field to\n require a certain constra\
int. This relaxes the need\n to inherit/subclass a Field you t\
o add a simple constraint.\n Returns true if the given value is\
within the Field's constraint.\n "
|
|
default
-
- Type:
-
unicode
- Value:
u'Default Value\n\nThe field default value may be None or a legal\n \
field value'
|
|
description
-
- Type:
-
unicode
- Value:
u'Description\n\nA description of the field'
|
|
missing_value
-
- Type:
-
unicode
- Value:
u"Missing Value\n\nIf input for this Field is missing, and that's ok,\\
n then this is the value to use"
|
|
order
-
- Type:
-
unicode
- Value:
u'Field Order\n\n The order attribute can be used to determine \
the order in\n which fields in a schema were defined. If one fi\
eld is created\n after another (in the same thread), its order \
will be\n greater.\n\n (Fields in separate threads could\
have the same order.)\n '
|
|
query
-
- Type:
-
str
- Value:
"""Query the value of the field for the given object.
Return the default if the value hasn't been set.
"""
|
|
readonly
-
- Type:
-
unicode
- Value:
u"Read Only\n\nIf true, the field's value cannot be changed."
|
|
required
-
- Type:
-
unicode
- Value:
u'Required\n\nTells whether a field requires its value to exist.'
|
|
set
-
- Type:
-
str
- Value:
'''Set the value of the field for the object
Raises a type error if the field is a read-only field.
'''
|
|
title
-
- Type:
-
unicode
- Value:
u'Title\n\nA short summary or label'
|
|
validate
-
- Type:
-
unicode
- Value:
u'Validate that the given value is a valid field value.\n\n Ret\
urns nothing but raises an error if the value is invalid.\n It \
checks everything specific to a Field and also checks\n with th\
e additional constraint.\n '
|
|