Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install menhir.contenttype.document

How to install menhir.contenttype.document

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install menhir.contenttype.document
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
0.1 Available View build log
Windows (64-bit)
0.2 Available View build log
0.1 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
0.1 Available View build log
Linux (32-bit)
0.2 Available View build log
0.1 Available View build log
Linux (64-bit)
0.2 Available View build log
0.1 Available View build log
 
License
GPL
Lastest release
version 0.2 on Mar 2nd, 2011

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

Subscribe to package updates

Last updated Mar 2nd, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.