schema.field - Special Schema Fields

Special fields.

class waeup.kofa.schema.field.CustomizableErrorMsg(not_in_vocab=<class 'zope.schema._bootstrapinterfaces.InvalidValue'>, **kw)[source]

Bases: object

__dict__ = dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x2b7266d672b0>, '__module__': 'waeup.kofa.schema.field', '__provides__': <zope.interface.declarations.ClassProvides object at 0x2b726be66f10>, '__dict__': <attribute '__dict__' of 'CustomizableErrorMsg' objects>, '__implemented__': <implementedBy waeup.kofa.schema.field.CustomizableErrorMsg>, '__weakref__': <attribute '__weakref__' of 'CustomizableErrorMsg' objects>, '__doc__': None, '__init__': <function __init__ at 0x2b726be537d0>})
__doc__ = None
__implemented__ = <implementedBy waeup.kofa.schema.field.CustomizableErrorMsg>
__init__(not_in_vocab=<class 'zope.schema._bootstrapinterfaces.InvalidValue'>, **kw)[source]
__module__ = 'waeup.kofa.schema.field'
__providedBy__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
__weakref__

list of weak references to the object (if defined)

class waeup.kofa.schema.field.FormattedDate(date_format=None, show_year=False, *args, **kw)[source]

Bases: zope.schema._field.Date

A date field that supports additional formatting attributes.

Stores extra attributes (see below). To make use of these attributes in forms, you have to provide widgets that read them and use them in their operations, for instance the waeup.kofa.widgets.datewidget.FormattedDateWidget.

Extra attributes are as follows:

date_format
additional attribute to describe desired date format. Must be a string that can be fed to strftime/strptime functions. By default None.
show_year
boolean indicating whether some kind of year selection should be used with this instance. False by default.
__doc__ = 'A date field that supports additional formatting attributes.\n\n Stores extra attributes (see below). To make use of these\n attributes in forms, you have to provide widgets that read them\n and use them in their operations, for instance the\n `waeup.kofa.widgets.datewidget.FormattedDateWidget`.\n\n Extra attributes are as follows:\n\n `date_format`\n additional attribute to describe desired date format. Must be a\n string that can be fed to strftime/strptime functions. By\n default `None`.\n\n `show_year`\n boolean indicating whether some kind of year selection should\n be used with this instance. `False` by default.\n '
__implemented__ = <implementedBy waeup.kofa.schema.field.FormattedDate>
__init__(date_format=None, show_year=False, *args, **kw)[source]
__module__ = 'waeup.kofa.schema.field'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
date_format = None
show_year = False
class waeup.kofa.schema.field.PhoneNumber(*args, **kw)[source]

Bases: zope.schema._bootstrapfields.TextLine

A schema field for phone numbers.

__doc__ = 'A schema field for phone numbers.\n '
__implemented__ = <implementedBy waeup.kofa.schema.field.PhoneNumber>
__module__ = 'waeup.kofa.schema.field'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
class waeup.kofa.schema.field.TextLineChoice(values=None, vocabulary=None, source=None, **kw)[source]

Bases: zope.schema._bootstrapfields.TextLine, waeup.kofa.schema.field.CustomizableErrorMsg

A TextLine field that also accepts sources, vocabs and values.

You can use this field like a regular zope.schema.TextLine field.

You can additionally give source, values or vocabulary parameters which will work mainly as with regular zope.schema.Choice fields (hence the name). Different to Choice field, these parameters are not mandatory. Leave them out and you have a regular TextLine field.

If you pass a simple source parameter, only those values are allowed which also appear in the source. The source should of course provide string values as suitable for TextLine fields only!

If, for example you create a TextLineChoice like this:

name = TextLineChoice(
title = u’Some name’, values = [u’foo’, u’bar’] # unicode allowed only! )

any formlib form rendering this field will only accept input u’foo’ or u’bar’.

The main advantage of this modified TextLine field is to support contextual sources. That means you can define some IContextSourceBinder component that looks up catalogs or something external else and decide then, whether the entered value of a form is allowed or not.

The code herein is mainly copied over from zope.schema._field.Choice with slight modifications.

__doc__ = "A TextLine field that also accepts sources, vocabs and values.\n\n You can use this field like a regular zope.schema.TextLine field.\n\n You can additionally give `source`, `values` or `vocabulary`\n parameters which will work mainly as with regular\n zope.schema.Choice fields (hence the name). Different to\n `Choice` field, these parameters are not mandatory. Leave them\n out and you have a regular `TextLine` field.\n\n If you pass a simple source parameter, only those values are\n allowed which also appear in the source. The source should of\n course provide string values as suitable for TextLine fields only!\n\n If, for example you create a TextLineChoice like this:\n\n name = TextLineChoice(\n title = u'Some name',\n values = [u'foo', u'bar'] # unicode allowed only!\n )\n\n any formlib form rendering this field will only accept input u'foo'\n or u'bar'.\n\n The main advantage of this modified TextLine field is to support\n contextual sources. That means you can define some\n IContextSourceBinder component that looks up catalogs or something\n external else and decide then, whether the entered value of a form\n is allowed or not.\n\n The code herein is mainly copied over from\n zope.schema._field.Choice with slight modifications.\n "
__implemented__ = <implementedBy waeup.kofa.schema.field.TextLineChoice>
__init__(values=None, vocabulary=None, source=None, **kw)[source]
__module__ = 'waeup.kofa.schema.field'
__provides__

Special descriptor for class __provides__

The descriptor caches the implementedBy info, so that we can get declarations for objects without instance-specific interfaces a bit quicker.

For example:

>>> from zope.interface import Interface
>>> class IFooFactory(Interface):
...     pass
>>> class IFoo(Interface):
...     pass
>>> class C(object):
...     implements(IFoo)
...     classProvides(IFooFactory)
>>> [i.getName() for i in C.__provides__]
['IFooFactory']
>>> [i.getName() for i in C().__provides__]
['IFoo']
_validate(value)[source]

First validate against the regular TextLine rules. Then check any vocabularies/sources.

bind(object)[source]

See zope.schema._bootstrapinterfaces.IField.

source