schema – Special Schema Fields Package

(see also: Submodules)

class waeup.kofa.schema.CustomizableErrorMsg(not_in_vocab=<class 'zope.schema._bootstrapinterfaces.InvalidValue'>, **kw)[source]
__dict__ = dict_proxy({'__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x7f402dea22c0>, '__module__': 'waeup.kofa.schema.field', '__provides__': <zope.interface.declarations.ClassProvides object at 0x7f40283271d0>, '__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 0x7f4028310668>})
__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.TextLineChoice(values=None, vocabulary=None, source=None, **kw)[source]

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
class waeup.kofa.schema.FormattedDate(date_format=None, show_year=False, *args, **kw)[source]

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.PhoneNumber(*args, **kw)[source]

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']

Submodules

This package bundles the following modules: