API

This document describes the low-level API of the interfaces and classes provided by this package. The narrative documentation is a better guide to the intended usage.

Interfaces

class zope.schema.interfaces.IField[source]

Bases: zope.interface.Interface

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 zope.schema.interfaces.IFromUnicode[source]

Bases: zope.interface.Interface

Parse a unicode string to a value

We will often adapt fields to this interface to support views and other applications that need to conver raw data as unicode values.

class zope.schema.interfaces.IChoice[source]

Bases: zope.schema.interfaces.IField

Field whose value is contained in a predefined set

Only one, values or vocabulary, may be specified for a given choice.

class zope.schema.interfaces.IContextAwareDefaultFactory[source]

Bases: zope.interface.Interface

A default factory that requires a context.

The context is the field context. If the field is not bound, context may be None.

class zope.schema.interfaces.IOrderable[source]

Bases: zope.schema.interfaces.IField

Field requiring its value to be orderable.

The set of value needs support a complete ordering; the implementation mechanism is not constrained. Either __cmp__() or ‘rich comparison’ methods may be used.

class zope.schema.interfaces.ILen[source]

Bases: zope.schema.interfaces.IField

A Field requiring its value to have a length.

The value needs to have a conventional __len__ method.

class zope.schema.interfaces.IMinMax[source]

Bases: zope.schema.interfaces.IOrderable

Field requiring its value to be between min and max.

This implies that the value needs to support the IOrderable interface.

class zope.schema.interfaces.IMinMaxLen[source]

Bases: zope.schema.interfaces.ILen

Field requiring the length of its value to be within a range

class zope.schema.interfaces.IInterfaceField[source]

Bases: zope.schema.interfaces.IField

Fields with a value that is an interface (implementing zope.interface.Interface).

class zope.schema.interfaces.IBool[source]

Bases: zope.schema.interfaces.IField

Boolean Field.

class zope.schema.interfaces.IObject[source]

Bases: zope.schema.interfaces.IField

Field containing an Object value.

class zope.schema.interfaces.IDict[source]

Bases: zope.schema.interfaces.IMinMaxLen, zope.schema.interfaces.IIterable, zope.schema.interfaces.IContainer

Field containing a conventional dict.

The key_type and value_type fields allow specification of restrictions for keys and values contained in the dict.

Strings

class zope.schema.interfaces.IBytes[source]

Bases: zope.schema.interfaces.IMinMaxLen, zope.schema.interfaces.IIterable, zope.schema.interfaces.IField

Field containing a byte string (like the python str).

The value might be constrained to be with length limits.

class zope.schema.interfaces.IBytesLine[source]

Bases: zope.schema.interfaces.IBytes

Field containing a byte string without newlines.

class zope.schema.interfaces.IText[source]

Bases: zope.schema.interfaces.IMinMaxLen, zope.schema.interfaces.IIterable, zope.schema.interfaces.IField

Field containing a unicode string.

class zope.schema.interfaces.ITextLine[source]

Bases: zope.schema.interfaces.IText

Field containing a unicode string without newlines.

class zope.schema.interfaces.IASCII[source]

Bases: zope.schema.interfaces.IBytes

Field containing a 7-bit ASCII string. No characters > DEL (chr(127)) are allowed

The value might be constrained to be with length limits.

class zope.schema.interfaces.IASCIILine[source]

Bases: zope.schema.interfaces.IASCII

Field containing a 7-bit ASCII string without newlines.

class zope.schema.interfaces.IPassword[source]

Bases: zope.schema.interfaces.ITextLine

Field containing a unicode string without newlines that is a password.

class zope.schema.interfaces.IURI[source]

Bases: zope.schema.interfaces.IBytesLine

A field containing an absolute URI

class zope.schema.interfaces.IId[source]

Bases: zope.schema.interfaces.IBytesLine

A field containing a unique identifier

A unique identifier is either an absolute URI or a dotted name. If it’s a dotted name, it should have a module/package name as a prefix.

class zope.schema.interfaces.IDottedName[source]

Bases: zope.schema.interfaces.IBytesLine

Dotted name field.

Values of DottedName fields must be Python-style dotted names.

Numbers

class zope.schema.interfaces.IInt[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing an Integer Value.

class zope.schema.interfaces.IFloat[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a Float.

class zope.schema.interfaces.IDecimal[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a Decimal.

Date/Time

class zope.schema.interfaces.IDatetime[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a DateTime.

class zope.schema.interfaces.IDate[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a date.

class zope.schema.interfaces.ITimedelta[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a timedelta.

class zope.schema.interfaces.ITime[source]

Bases: zope.schema.interfaces.IMinMax, zope.schema.interfaces.IField

Field containing a time.

Collections

class zope.schema.interfaces.IIterable[source]

Bases: zope.schema.interfaces.IField

Fields with a value that can be iterated over.

The value needs to support iteration; the implementation mechanism is not constrained. (Either __iter__() or __getitem__() may be used.)

class zope.schema.interfaces.IContainer[source]

Bases: zope.schema.interfaces.IField

Fields whose value allows an x in value check.

The value needs to support the in operator, but is not constrained in how it does so (whether it defines __contains__() or __getitem__() is immaterial).

class zope.schema.interfaces.ICollection[source]

Bases: zope.schema.interfaces.IMinMaxLen, zope.schema.interfaces.IIterable, zope.schema.interfaces.IContainer

Abstract interface containing a collection value.

The Value must be iterable and may have a min_length/max_length.

class zope.schema.interfaces.ISequence[source]

Bases: zope.schema.interfaces.ICollection

Abstract interface specifying that the value is ordered

class zope.schema.interfaces.IUnorderedCollection[source]

Bases: zope.schema.interfaces.ICollection

Abstract interface specifying that the value cannot be ordered

class zope.schema.interfaces.IAbstractSet[source]

Bases: zope.schema.interfaces.IUnorderedCollection

An unordered collection of unique values.

class zope.schema.interfaces.IAbstractBag[source]

Bases: zope.schema.interfaces.IUnorderedCollection

An unordered collection of values, with no limitations on whether members are unique

class zope.schema.interfaces.ITuple[source]

Bases: zope.schema.interfaces.ISequence

Field containing a value that implements the API of a conventional Python tuple.

class zope.schema.interfaces.IList[source]

Bases: zope.schema.interfaces.ISequence

Field containing a value that implements the API of a conventional Python list.

class zope.schema.interfaces.ISet[source]

Bases: zope.schema.interfaces.IAbstractSet

Field containing a value that implements the API of a Python2.4+ set.

class zope.schema.interfaces.IFrozenSet[source]

Bases: zope.schema.interfaces.IAbstractSet

Field containing a value that implements the API of a conventional Python 2.4+ frozenset.

Events

class zope.schema.interfaces.IBeforeObjectAssignedEvent[source]

Bases: zope.interface.Interface

An object is going to be assigned to an attribute on another object.

Subscribers to this event can change the object on this event to change what object is going to be assigned. This is useful, e.g. for wrapping or replacing objects before they get assigned to conform to application policy.

class zope.schema.interfaces.IFieldEvent[source]

Bases: zope.interface.Interface

class zope.schema.interfaces.IFieldUpdatedEvent[source]

Bases: zope.schema.interfaces.IFieldEvent

A field has been modified

Subscribers will get the old and the new value together with the field

Vocabularies

class zope.schema.interfaces.ITerm[source]

Bases: zope.interface.Interface

Object representing a single value in a vocabulary.

class zope.schema.interfaces.ITokenizedTerm[source]

Bases: zope.schema.interfaces.ITerm

Object representing a single value in a tokenized vocabulary.

class zope.schema.interfaces.ITitledTokenizedTerm[source]

Bases: zope.schema.interfaces.ITokenizedTerm

A tokenized term that includes a title.

class zope.schema.interfaces.ISource[source]

Bases: zope.interface.Interface

A set of values from which to choose

Sources represent sets of values. They are used to specify the source for choice fields.

Sources can be large (even infinite), in which case, they need to be queried to find out what their values are.

class zope.schema.interfaces.ISourceQueriables[source]

Bases: zope.interface.Interface

A collection of objects for querying sources

class zope.schema.interfaces.IContextSourceBinder[source]

Bases: zope.interface.Interface

class zope.schema.interfaces.IBaseVocabulary[source]

Bases: zope.schema.interfaces.ISource

Representation of a vocabulary.

At this most basic level, a vocabulary only need to support a test for containment. This can be implemented either by __contains__() or by sequence __getitem__() (the later only being useful for vocabularies which are intrinsically ordered).

class zope.schema.interfaces.IIterableVocabulary[source]

Bases: zope.interface.Interface

Vocabulary which supports iteration over allowed values.

The objects iteration provides must conform to the ITerm interface.

class zope.schema.interfaces.IIterableSource[source]

Bases: zope.schema.interfaces.ISource

Source which supports iteration over allowed values.

The objects iteration provides must be values from the source.

class zope.schema.interfaces.IVocabulary[source]

Bases: zope.schema.interfaces.IIterableVocabulary, zope.schema.interfaces.IBaseVocabulary

Vocabulary which is iterable.

class zope.schema.interfaces.IVocabularyTokenized[source]

Bases: zope.schema.interfaces.IVocabulary

Vocabulary that provides support for tokenized representation.

Terms returned from getTerm() and provided by iteration must conform to ITokenizedTerm.

class zope.schema.interfaces.ITreeVocabulary[source]

Bases: zope.schema.interfaces.IVocabularyTokenized, zope.interface.common.mapping.IEnumerableMapping

A tokenized vocabulary with a tree-like structure.

The tree is implemented as dictionary, with keys being ITokenizedTerm terms and the values being similar dictionaries. Leaf values are empty dictionaries.

class zope.schema.interfaces.IVocabularyRegistry[source]

Bases: zope.interface.Interface

Registry that provides IBaseVocabulary objects for specific fields.

class zope.schema.interfaces.IVocabularyFactory[source]

Bases: zope.interface.Interface

Can create vocabularies.

Exceptions

exception zope.schema._bootstrapinterfaces.ValidationError[source]

Bases: zope.interface.exceptions.Invalid

Raised if the Validation process fails.

exception zope.schema.ValidationError

The preferred alias for zope.schema._bootstrapinterfaces.ValidationError.

exception zope.schema.interfaces.StopValidation[source]

Bases: exceptions.Exception

Raised if the validation is completed early.

Note that this exception should be always caught, since it is just a way for the validator to save time.

exception zope.schema.interfaces.RequiredMissing[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Required input is missing.

exception zope.schema.interfaces.WrongType[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Object is of wrong type.

exception zope.schema.interfaces.ConstraintNotSatisfied[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Constraint not satisfied

exception zope.schema.interfaces.NotAContainer[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Not a container

exception zope.schema.interfaces.NotAnIterator[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Not an iterator

exception zope.schema.interfaces.TooSmall[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Value is too small

exception zope.schema.interfaces.TooBig[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Value is too big

exception zope.schema.interfaces.TooLong[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Value is too long

exception zope.schema.interfaces.TooShort[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Value is too short

exception zope.schema.interfaces.InvalidValue[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Invalid value

exception zope.schema.interfaces.WrongContainedType[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Wrong contained type

exception zope.schema.interfaces.NotUnique[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

One or more entries of sequence are not unique.

exception zope.schema.interfaces.SchemaNotFullyImplemented[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Schema not fully implemented

exception zope.schema.interfaces.SchemaNotProvided[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

Schema not provided

exception zope.schema.interfaces.InvalidURI[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

The specified URI is not valid.

exception zope.schema.interfaces.InvalidId[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

The specified id is not valid.

exception zope.schema.interfaces.InvalidDottedName[source]

Bases: zope.schema._bootstrapinterfaces.ValidationError

The specified dotted name is not valid.

exception zope.schema.interfaces.Unbound[source]

Bases: exceptions.Exception

The field is not bound.

Schema APIs

zope.schema.getFields(schema)[source]

Return a dictionary containing all the Fields in a schema.

zope.schema.getFieldsInOrder(schema, _field_key=<function <lambda>>)[source]

Return a list of (name, value) tuples in native schema order.

zope.schema.getFieldNames(schema)[source]

Return a list of all the Field names in a schema.

zope.schema.getFieldNamesInOrder(schema)[source]

Return a list of all the Field names in a schema in schema order.

zope.schema.getValidationErrors(schema, object)[source]

Return a list of all validation errors.

zope.schema.getSchemaValidationErrors(schema, object)[source]

Fields

class zope.schema.Field(title=u'', description=u'', __name__='', required=True, readonly=False, constraint=None, default=None, defaultFactory=None, missing_value=<object object>)[source]

Bases: zope.interface.interface.Attribute

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')
class zope.schema._field.AbstractCollection(value_type=None, unique=False, **kw)[source]

Bases: zope.schema._bootstrapfields.MinMaxLen, zope.schema._bootstrapfields.Iterable

bind(object)[source]

See zope.schema._bootstrapinterfaces.IField.

class zope.schema.ASCII(min_length=0, max_length=None, **kw)[source]

Field containing a 7-bit ASCII string. No characters > DEL (chr(127)) are allowed

The value might be constrained to be with length limits.

class zope.schema.ASCIILine(min_length=0, max_length=None, **kw)[source]

Field containing a 7-bit ASCII string without newlines.

class zope.schema.Bool(title=u'', description=u'', __name__='', required=True, readonly=False, constraint=None, default=None, defaultFactory=None, missing_value=<object object>)[source]

A field representing a Bool.

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')
fromUnicode(str)[source]
>>> from zope.schema._bootstrapfields import Bool
>>> from zope.schema.interfaces import IFromUnicode
>>> b = Bool()
>>> IFromUnicode.providedBy(b)
True
>>> b.fromUnicode('True')
True
>>> b.fromUnicode('')
False
>>> b.fromUnicode('true')
True
>>> b.fromUnicode('false') or b.fromUnicode('False')
False
class zope.schema.Bytes(min_length=0, max_length=None, **kw)[source]

Field containing a byte string (like the python str).

The value might be constrained to be with length limits.

fromUnicode(uc)[source]

See IFromUnicode.

class zope.schema.BytesLine(min_length=0, max_length=None, **kw)[source]

A Text field with no newlines.

class zope.schema.Choice(values=None, vocabulary=None, source=None, **kw)[source]

Choice fields can have a value found in a constant or dynamic set of values given by the field definition.

Initialize object.

bind(object)[source]

See zope.schema._bootstrapinterfaces.IField.

fromUnicode(str)[source]

See IFromUnicode.

class zope.schema.Container(title=u'', description=u'', __name__='', required=True, readonly=False, constraint=None, default=None, defaultFactory=None, missing_value=<object object>)[source]

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')
class zope.schema.Date(min=None, max=None, default=None, **kw)[source]

Field containing a date.

class zope.schema.Datetime(*args, **kw)[source]

Field containing a DateTime.

class zope.schema.Decimal(*args, **kw)[source]

Field containing a Decimal.

fromUnicode(uc)[source]

See IFromUnicode.

class zope.schema.Dict(key_type=None, value_type=None, **kw)[source]

A field representing a Dict.

bind(object)[source]

See zope.schema._bootstrapinterfaces.IField.

class zope.schema.DottedName(*args, **kw)[source]

Dotted name field.

Values of DottedName fields must be Python-style dotted names.

class zope.schema.Float(*args, **kw)[source]

Field containing a Float.

fromUnicode(uc)[source]

See IFromUnicode.

class zope.schema.FrozenSet(**kw)[source]
class zope.schema.Id(min_length=0, max_length=None, **kw)[source]

Id field

Values of id fields must be either uris or dotted names.

fromUnicode(value)[source]

See IFromUnicode.

class zope.schema.Int(*args, **kw)[source]

A field representing an Integer.

fromUnicode(str)[source]
>>> from zope.schema._bootstrapfields import Int
>>> f = Int()
>>> f.fromUnicode("125")
125
>>> f.fromUnicode("125.6") 
Traceback (most recent call last):
...
ValueError: invalid literal for int(): 125.6
class zope.schema.InterfaceField(title=u'', description=u'', __name__='', required=True, readonly=False, constraint=None, default=None, defaultFactory=None, missing_value=<object object>)[source]

Fields with a value that is an interface (implementing zope.interface.Interface).

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')
class zope.schema.Iterable(title=u'', description=u'', __name__='', required=True, readonly=False, constraint=None, default=None, defaultFactory=None, missing_value=<object object>)[source]

Pass in field values as keyword parameters.

Generally, you want to pass either a title and description, or a doc string. If you pass no doc string, it will be computed from the title and description. If you pass a doc string that follows the Python coding style (title line separated from the body by a blank line), the title and description will be computed from the doc string. Unfortunately, the doc string must be passed as a positional argument.

Here are some examples:

>>> from zope.schema._bootstrapfields import Field
>>> f = Field()
>>> f.__doc__, str(f.title), str(f.description)
('', '', '')
>>> f = Field(title=u'sample')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample', 'sample', '')
>>> f = Field(title=u'sample', description=u'blah blah\nblah')
>>> str(f.__doc__), str(f.title), str(f.description)
('sample\n\nblah blah\nblah', 'sample', 'blah blah\nblah')
class zope.schema.List(value_type=None, unique=False, **kw)[source]

Bases: zope.schema._field.AbstractCollection

A field representing a List.

class zope.schema.MinMaxLen(min_length=0, max_length=None, **kw)[source]

Bases: object

Expresses constraints on the length of a field.

MinMaxLen is a mixin used in combination with Field.

zope.schema.NativeString

alias of Bytes

zope.schema.NativeStringLine

alias of BytesLine

class zope.schema.Object(schema, **kw)[source]

Field containing an Object value.

class zope.schema.Orderable(min=None, max=None, default=None, **kw)[source]

Bases: object

Values of ordered fields can be sorted.

They can be restricted to a range of values.

Orderable is a mixin used in combination with Field.

class zope.schema.Password(*args, **kw)[source]

A text field containing a text used as a password.

set(context, value)[source]

Update the password.

We use a special marker value that a widget can use to tell us that the password didn’t change. This is needed to support edit forms that don’t display the existing password and want to work together with encryption.

class zope.schema.Set(**kw)[source]

Bases: zope.schema._field.AbstractCollection

A field representing a set.

class zope.schema.SourceText(*args, **kw)[source]

Field for source text of object.

class zope.schema.Text(*args, **kw)[source]

A field containing text used for human discourse.

fromUnicode(str)[source]
>>> from zope.schema import Text
>>> t = Text(constraint=lambda v: 'x' in v)
>>> t.fromUnicode(b"foo x spam")
Traceback (most recent call last):
...
WrongType: ('foo x spam', <type 'unicode'>, '')
>>> result = t.fromUnicode(u"foo x spam")
>>> isinstance(result, bytes)
False
>>> str(result)
'foo x spam'
>>> t.fromUnicode(u"foo spam")
Traceback (most recent call last):
...
ConstraintNotSatisfied: (u'foo spam', '')
class zope.schema.TextLine(*args, **kw)[source]

A text field with no newlines.

class zope.schema.Time(min=None, max=None, default=None, **kw)[source]

Field containing a time.

class zope.schema.Timedelta(min=None, max=None, default=None, **kw)[source]

Field containing a timedelta.

class zope.schema.Tuple(value_type=None, unique=False, **kw)[source]

Bases: zope.schema._field.AbstractCollection

A field representing a Tuple.

class zope.schema.URI(min_length=0, max_length=None, **kw)[source]

URI schema field

fromUnicode(value)[source]

See IFromUnicode.

Accessors

Field accessors

Accessors are used to model methods used to access data defined by fields. Accessors are fields that work by decorating existing fields.

To define accessors in an interface, use the accessors function:

class IMyInterface(Interface):

   getFoo, setFoo = accessors(Text(title=u'Foo', ...))

   getBar = accessors(TextLine(title=u'Foo', readonly=True, ...)

Normally a read accessor and a write accessor are defined. Only a read accessor is defined for read-only fields.

Read accessors function as access method specifications and as field specifications. Write accessors are solely method specifications.

class zope.schema.accessors.FieldReadAccessor(field)[source]

Bases: zope.interface.interface.Method

Field read accessor

zope.schema.accessors.accessors(field)[source]