Dolmen applications content utilities
Project description
dolmen.app.content provides out-of-the-box utilities for Dolmen applications content.
Getting started
We import Grok and grok the package:
>>> import grok
>>> grok.testing.grok('dolmen.app.content')
We create a dolmen.content content:
>>> import dolmen.content
>>> class Mammoth(dolmen.content.Content):
... grok.name('A furry thing')
>>> manfred = Mammoth()
>>> manfred.title = u'A nice mammoth'
Indexes
dolmen.app.content registers two indexes to catalog the dolmen.content.IBaseContent created inside a Dolmen application:
>>> from dolmen.app.content import indexes
Base indexes
The dolmen.app.content.indexes.BaseIndexes handles the title and the content type of an IBaseContent content:
>>> indexes.BaseIndexes.__grok_indexes__
{'content_type': <grok.index.Field object at ...>, 'title': <grok.index.Text object at ...>}
>>> indexes.BaseIndexes.__grok_indexes__['content_type']._attribute
'__content_type__'
Searchable text
dolmen.app.content provides a simple ‘ISearchableText’ implementation, allowing full text searches. It comes in two parts.
The index:
>>> indexes.SearchableIndex.__grok_indexes__
{'searchabletext': <grok.index.Text object at ...>}
The adapter:
>>> from zope.index.text.interfaces import ISearchableText >>> adapter = ISearchableText(manfred) >>> adapter.getSearchableText() u'A nice mammoth'
Thumbnailing
Thanks to dolmen.thumbnailer, dolmen.app.content provides a base thumbnailing policy, using ZODB blobs as storage and introducing a new scale.
Scales
Let’s introspect our Miniaturizer component:
>>> from dolmen.app.content import thumbnails
>>> thumbnails.BlobMiniaturizer.factory
<class 'dolmen.blob.file.BlobValue'>
>>> print thumbnails.BlobMiniaturizer.scales
{'mini': (250, 250), 'square': (64, 64), 'thumb': (150, 150), 'large': (700, 700), 'small': (128, 128), 'preview': (400, 400)}
The new scale, ‘square’, scales down and crops the original image to provide a square thumbnail. This is done using a IThumbnailer adapter:
>>> from dolmen.thumbnailer import IThumbnailer >>> thumbnails.SquareThumbnailer <class 'dolmen.app.content.thumbnails.SquareThumbnailer'> >>> IThumbnailer.implementedBy(thumbnails.SquareThumbnailer) True
Credits
All Dolmen packages are sponsorised by NPAI (http://www.npai.fr)
Changelog
0.1 (2009-11-02)
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
File details
Details for the file dolmen.app.content-0.1.tar.gz.
File metadata
- Download URL: dolmen.app.content-0.1.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f933f4cb00beeb02a696b17110cfc4b93417ac7c170289eae40f7a8036dd1eb2
|
|
| MD5 |
f1746b300175e452dfb9fd9d94e49da0
|
|
| BLAKE2b-256 |
54f02e5a649caa2960fa23d0bbefc43e1093cd8027e1bc69afe6d82f41bd84cb
|