Interfaces¶
The below are abstract interfaces expected to be fulfilled by various Deform implementations.
Interfaces.
- class deform.interfaces.FileUploadTempStore¶
The
deform.FileUploadWidgetrequires as its first argument atmpstore. Such a tmpstore will implement this interface: an object implementing the FileUploadTempStore interface should implement the methods attached to this description.Effectively, this interface is a subset of the
dictinterface plus an additional method namedpreview_url. In fact, the simplest possible implementation of this interface is:class MemoryTmpStore(dict): def preview_url(self, name): return None
However, the
deform.FileUploadWidgetdoes not remove data from the tempstore implementation it uses (it doesn't have enough information to be able to do so), and it is job of the tempstore implementation itself to expire items which haven't been accessed in a while.Therefore, the above
MemoryTmpStoreimplementation is generally unsuitable for production, as the data put into it is not automatically evicted over time and file upload data provided by untrusted users is usually unsuitable for storage in RAM. It's more likely that an implementation in your application will center around a sessioning library (such as Beaker) that does data eviction and which stores file upload data in persistent storage.- get(name, default=None)¶
Same as dict.get.
- __getitem__(name)¶
Get a value.
- __setitem__(name, value)¶
Set a value.
- __contains__(name)¶
This should return True if we have a value for the name supplied, False otherwise.
- preview_url(name)¶
Return the preview URL for the item previously placed into the tmpstore named
nameorNoneif there is no preview fornameavailable (or if this tmpstore does not support previewable items). This item should typically return a URL to a thumbnail image.