menhir.contenttype.document
menhir.contenttype.document provides a text-centered content for Dolmen based Grok applications. This document type has a field allowing a WYSIWYG edition and indexes itself for full-text searches.
Schema
A Document has a dedicated schema defining a text field, in addition of the base IDescriptiveSchema:
>>> from dolmen.app.content import IDescriptiveSchema >>> from menhir.contenttype.document import IDocument >>> IDocument.isOrExtends(IDescriptiveSchema) True >>> from dolmen.content import schema >>> from menhir.contenttype.document import Document >>> IDocument in schema.bind().get(Document) True
The text field is called “body”, as it is the document’s body text:
>>> for attr, doc in IDocument.namesAndDescriptions(): ... print attr, ':', doc body : <zope.schema...Text object at ...>
Factory
In order to create a Document content, the current user will have to be granted the dolmen.content.Add permission, from the dolmen.app.security package:
>>> from dolmen.content import require >>> require.bind().get(Document) 'dolmen.content.Add'
Forms
The WYSIWYG widget is provided by dolmen.widget.tinymce, using the javascript library TinyMCE and jQuery. The Add form and the Edit form will display the widget, since menhir.contenttype.document provides a FieldsCustomizer adapter (see dolmen.forms.crud documentation):
>>> from dolmen.forms.crud import Edit >>> mydoc = Document(title=u'Some title', body=u"Some body") >>> from zope.publisher.browser import TestRequest >>> request = TestRequest() >>> editform = Edit(mydoc, request) >>> editform.update() >>> editform.fields['body'].mode <Marker TINYMCE.INPUT>
Indexation
A Document is indexed in full-text, using an ISearchableText adapter:
>>> from zope.index.text.interfaces import ISearchableText >>> indexer = ISearchableText(mydoc) >>> indexer.getSearchableText() (u'Some title', u'', u'Some body\n\n') >>> mydoc.body = u'<p>Rich content comes in <strong>HTML</strong></p>' >>> indexer.getSearchableText() (u'Some title', u'', u'Rich content comes in **HTML**\n\n') >>> mydoc.description = u"I'm described" >>> indexer.getSearchableText() (u'Some title', u"I'm described", u'Rich content comes in **HTML**\n\n')
View
A Document has its very own index view, allowing it to render in a simple way, without the default field names (see dolmen.forms.crud):
>>> from zope.component import getMultiAdapter >>> view = getMultiAdapter((mydoc, request), name='index') >>> from dolmen.app.layout import Page >>> isinstance(view, Page) True >>> print view.content() <div class="document"> <h1>Some title</h1> <p>Rich content comes in <strong>HTML</strong></p> </div>
Changelog
0.2 (2011-02-14)
Updated to use IDescriptiveContent from dolmen.app.content instead of IBaseContent from dolmen.content that non longer exists : a document now has a description attribute in addition to title. This change has been echoed in the indexer.
Updated dependencies.
0.1 (2010-07-20)
Initial release
Metadata
Release files for menhir.contenttype.document 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| menhir.contenttype.document-0.2.tar.gz | 5.5 kB | Without provenance | Details for menhir.contenttype.document-0.2.tar.gz |
Release files / menhir.contenttype.document-0.2.tar.gz
| Download URL | menhir.contenttype.document-0.2.tar.gz |
|---|---|
| Size | 5.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be4c72efb1d259f966c3b58d0e46c808b1809b6ae68f5b253b2659970693b16a
|
|
BLAKE2b-256 checksum How to use checksums |
5dc0c94711398aa6a19322324c276ba8076104191ead35f82e75e35b567ae7b8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for menhir.contenttype.document 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.