Storage

In Zope environments there are many possible types of objects which can have images, and just as many ways to store an image. In order to handle all of these two types of adapters are used: an IImageData adapter which can retrieve the data from an image field and an IImageScaleStorage adapter which manages generation and retrieval of scaled images of fields on an object.

Scales can be retrieved using either their scaling parameters or via an identification code generated by the storage.

Interfaces

interface plone.scale.storage.IImageScaleStorage

This is an adapter for image content which can store, retrieve and generate image scale data. It provides a dictionary interface to existing image scales using the scale id as key. To find or create a scale based on its scaling parameters use the scale() method.

scale(factory=None, **parameters)
Find image scale data for the given parameters or create it if a factory was provided. The parameters will be passed back to the factory method, which is expected to return a tuple containing a representation of the actual image scale data (i.e. a string or file-like object) as well as the image’s format and dimensions. For convenience, this happens to match the return value of scaleImage, but makes it possible to use different storages, i.e. ZODB blobs
__getitem__(uid)
Find image scale data based on its uid.
__init__(context, modified=None)
Adapt the given context item and optionally provide a callable to return a representation of the last modification date, which can be used to invalidate stored scale data on update.

Classes

class plone.scale.storage.AnnotationStorage(context, modified=None)
An abstract storage for image scale data using annotations and implementing IImageScaleStorage. Image data is stored as an annotation on the object container, i.e. the image. This is needed since not all images are themselves annotatable.

Table Of Contents

Previous topic

Scaling

Next topic

Changelog

This Page