File content type for Grok and Dolmen applications.
Project description
menhir.contenttype.file provides a content type for Dolmen based Grok applications.
Schema
The menhir.contenttype.file provides a very simple schema, extending the IBaseContent interface, from dolmen.content:
>>> from dolmen.content import IBaseContent >>> from menhir.contenttype.file import IFile >>> IFile.isOrExtends(IBaseContent) True
The IFile interface describes the data field, that is to hold the uploaded file or given bytes:
>>> for attr, doc in IFile.namesAndDescriptions(): ... print attr, ':', doc data : <dolmen.file.field.FileField object at ...>
This IFile is directly provided by the File object, as defines it as its schema:
>>> from menhir.contenttype.file import File >>> somefile = File(title=u"My nice file", data="Some file data") >>> IFile.providedBy(somefile) True >>> from dolmen.content import schema >>> IFile in schema.bind().get(somefile) True >>> somefile.title u'My nice file'
Storage
The file uses a Blob storage for the data:
>>> somefile.data <dolmen.blob.file.BlobValue object at ...> >>> print somefile.data.data Some file data
Icon
The content registers an icon, thanks to the dolmen.app.content package:
>>> from zope.component import getMultiAdapter >>> from zope.publisher.browser import TestRequest >>> request = TestRequest() >>> icon = getMultiAdapter((somefile, request), name="icon") >>> print icon <zope.browserresource.icon.IconView object at ...>
Changelog
0.1 (2010-07-16)
Initial release
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for menhir.contenttype.file-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b9be15f5909311eef8020e3e4effa281b03c571f256fa02798d8d54307b2814 |
|
MD5 | 5f2991e3c61f5708f42c84590cf97e11 |
|
BLAKE2b-256 | 6b4a023fe11849e274c48440c353db2339b2a7a8e08bc6ad98f565b4ae32a0ba |