Grok-like directives for creating Dexterity content
Project description
This package provides optional, Grok-like directives for configuring Dexterity content. It depends on five.grok, which in turn depends on the various re-usable grokcore.* packages, but not Grok itself.
See also plone.directives.form, which provides directives for configuring schema interfaces with form hints.
Content classes
Content extending the Dexterity ‘Item’ and ‘Container’ base classes can be grokked in order to register a factory and/or ZMI add permission.
For example:
from plone.directives import dexterity from plone.directives import form from five import grok class IPage(form.Schema): title = schema.TextLine(title=u"Title") description = schema.Text(title=u"Description", description=u"Summary of the body") body = schema.Text(title=u"Body text", required=False, default=u"Body text goes here") details = schema.Text(title=u"Details", required=False) class FSPage(dexterity.Item): grok.implements(IPage) grok.name('example.page') def __init__(self, id=None, title=None, description=None, body=None, details=None): self.id = id # required - or call super() with this argument self.title = title self.description = description self.body = body self.details = details
This will register a factory utility if one is not already present with the name ‘example.fspage’.
You can also use the ‘add_permission()’ directive to cause the type to be registered as a Zope 2 content class, in the same way that the <five:registerClass /> directive does:
class ZopeTwoItem(dexterity.Item): grok.implements(IPage) dexterity.add_permission('cmf.AddPortalContent') portal_type = 'example.zopetwopage'
However, for most content types, this will be unnecessary.
Forms
To create a Dexterity add-, edit- or display form for your type, use the AddForm, EditForm or DisplayForm base classes. For example:
from plone.directives import dexterity from plone.directives import form from five import grok class IPage(form.Schema): title = schema.TextLine(title=u"Title") description = schema.Text(title=u"Description", description=u"Summary of the body") body = schema.Text(title=u"Body text", required=False, default=u"Body text goes here") details = schema.Text(title=u"Details", required=False) class View(dexterity.DisplayForm): """The view. May will a template from <modulename>_templates/view.pt, and will be called 'view' unless otherwise stated. """ grok.require('zope2.View') grok.context(IPage) class Edit(dexterity.EditForm): """A standard edit form. """ grok.context(IPage) def updateWidget(self): super(Edit, self).updateWidgets() self.widgets['title'].mode = 'hidden'
Changelog
1.0a2 - 2009-11-17
Fix deprecation warnings on Zope 2.12 [optilude]
1.0a1 - 2009-07-25
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
Hashes for plone.directives.dexterity-1.0a2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25b7dfd4493b32ffea2e5067f19049d635f4fdf8dd1b98c9f0c8e39f04559297 |
|
MD5 | 120f760fe663b284786a01dbe42d4b59 |
|
BLAKE2b-256 | 7ca7134f81ec3ec4b87cfbe9629f1a7930512c5fd12dad7d4b5c0a1d82200e5d |