image.schema - Image File Schemas

Image file schemas.

class waeup.kofa.image.schema.ImageFile(min_size=None, max_size=None, **kw)[source]

Bases: waeup.kofa.image.schema.MinMaxSize, hurry.file.schema.File

An image file field.

Suitable for interfaces that wish to store image files in an attribute.

This field type supports MinMaxSize so that you can set min_size or max_size for all ImageFile fields in your interfaces like this:

class MyInterface(Interface):
image = ImageFile(
title = u’The image’, description = u’The nice image’, max_size = 1024 * 10, )

to restrict the file size of stored images to 10 KBytes.

By default no such restriction is set.

__doc__ = "An image file field.\n\n Suitable for interfaces that wish to store image files in an\n attribute.\n\n This field type supports `MinMaxSize` so that you can set\n `min_size` or `max_size` for all `ImageFile` fields in your\n interfaces like this:\n\n class MyInterface(Interface):\n image = ImageFile(\n title = u'The image',\n description = u'The nice image',\n max_size = 1024 * 10,\n )\n\n to restrict the file size of stored images to 10 KBytes.\n\n By default no such restriction is set.\n "
__implemented__ = <implementedBy waeup.kofa.image.schema.ImageFile>
__module__ = 'waeup.kofa.image.schema'
__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']
_type

alias of KofaImageFile

class waeup.kofa.image.schema.MinMaxSize(min_size=None, max_size=None, **kw)[source]

Bases: object

Expresses constraints on the size of an object.

The ‘size’ of an object is determined by its size method or attribute. If an object has no such ‘size’ then it cannot be validated by this mixin.

Please do not confuse MinMaxSize with MinMaxLen, for instance supported by ordinary text fields. These test on len(obj) which is not necessary possible for file-like objects.

Therefore we distinguish ‘size’ from ‘len’ here.

__dict__ = dict_proxy({'__module__': 'waeup.kofa.image.schema', '_validate': <function _validate at 0x2b726f57f9b0>, 'min_size': None, '__dict__': <attribute '__dict__' of 'MinMaxSize' objects>, '__implemented__': <implementedBy waeup.kofa.image.schema.MinMaxSize>, '__weakref__': <attribute '__weakref__' of 'MinMaxSize' objects>, '__init__': <function __init__ at 0x2b726f57fed8>, '__providedBy__': <_interface_coptimizations.ObjectSpecificationDescriptor object at 0x2b7266d672b0>, '__provides__': <zope.interface.declarations.ClassProvides object at 0x2b726fe6fad0>, 'max_size': None, '__doc__': "Expresses constraints on the size of an object.\n\n The 'size' of an object is determined by its `size` method or\n attribute. If an object has no such 'size' then it cannot be\n validated by this mixin.\n\n Please do not confuse `MinMaxSize` with `MinMaxLen`, for instance\n supported by ordinary text fields. These test on ``len(obj)``\n which is not necessary possible for file-like objects.\n\n Therefore we distinguish 'size' from 'len' here.\n "})
__doc__ = "Expresses constraints on the size of an object.\n\n The 'size' of an object is determined by its `size` method or\n attribute. If an object has no such 'size' then it cannot be\n validated by this mixin.\n\n Please do not confuse `MinMaxSize` with `MinMaxLen`, for instance\n supported by ordinary text fields. These test on ``len(obj)``\n which is not necessary possible for file-like objects.\n\n Therefore we distinguish 'size' from 'len' here.\n "
__implemented__ = <implementedBy waeup.kofa.image.schema.MinMaxSize>
__init__(min_size=None, max_size=None, **kw)[source]
__module__ = 'waeup.kofa.image.schema'
__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)

_validate(value)[source]
max_size = None
min_size = None