Description
Dexterity content subsystem for Plone: info for the developers.
Dexterity is a subsystem for content objects. It is intended to replace the default Archetypes system from Plone 5 and onward and can be already used with Plone 4.
Please see ZopeSkel page for project skeleton templates for Dexterity.
Here is an example how to create your own add-on using the buildout below
cd src
../bin/paster create -t dexterity yourcompany.app
Edit buildout.cfg and add:
eggs =
yourcompany.app
develop =
src/yourcompany.app
Then rerun buildout to get your new add-on skeleton included in the configuration
cd ..
bin/buildout
Now you can start adding content into your add-on
cd src/yourcompany.app
../../bin/paster # Shows availablility of addcontent command
../../bin/paster addcontent -l # Shows available templates (content, field, behavior, etc...)
Below is a sample example which will install
Please tune the versions according the latest available releases.
buildout.cfg:
[buildout]
parts =
instance
zopepy
i18ndude
zopeskel
test
paster
omelette
extends =
http://dist.plone.org/release/4.1b1/versions.cfg
http://good-py.appspot.com/release/dexterity/1.0b7?plone=4.1b1
# Add additional egg download sources here. dist.plone.org contains archives
# of Plone packages.
find-links =
http://dist.plone.org/release/4.1b1
http://dist.plone.org/thirdparty
extensions =
mr.developer
buildout.dumppickedversions
buildout.threatlevel
sources = sources
versions = versions
# Reference any folders where you have Python egg source code under development here
# e.g.: develop = src/my.package
# If you are using the mr.developer extension and have the source code in a
# repository mr.developer will handle this automatically for you
develop =
# Create bin/instance command to manage Zope start up and shutdown
[instance]
recipe = plone.recipe.zope2instance
user = admin:admin
http-address = 8080
debug-mode = off
verbose-security = on
blob-storage = var/blobstorage
eggs =
Plone
plone.app.dexterity
# Some pre-Plone 3.3 packages may need you to register the package name here in
# order their configure.zcml to be run (http://plone.org/products/plone/roadmap/247)
# - this is never required for packages in the Products namespace (Products.*)
zcml =
# zopepy commands allows you to execute Python scripts using a PYTHONPATH
# including all the configured eggs
[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
scripts = zopepy
# create bin/i18ndude command
[i18ndude]
unzip = true
recipe = zc.recipe.egg
eggs = i18ndude
# create bin/test command
[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
${instance:eggs}
[paster]
recipe = zc.recipe.egg
eggs =
ZopeSkel
PasteScript
PasteDeploy
zopeskel.dexterity
${instance:eggs}
entry-points = paster=paste.script.command:run
# create ZopeSkel command
[zopeskel]
unzip = true
recipe = zc.recipe.egg
eggs =
ZopeSkel
${instance:eggs}
# symlinks all Python source code to parts/omelette folder when buildout is run
# windows users will need to install additional software for this part to build
# correctly. See http://pypi.python.org/pypi/collective.recipe.omelette for
# relevant details.
[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}
# Put your mr.developer managed source code repositories here, see
# http://pypi.python.org/pypi/mr.developer for details on format for this part
[sources]
collective.developermanual = svn http://svn.plone.org/svn/collective/collective.developermanual
# Version pindowns for new style products go here - this section extends one provided in http://dist.plone.org/release/
[versions]
By default, (global) Dexterity content types are addable to a folder if the editor has the cmf.AddPortalContent permission.
You might want to fine-tune permissions so that only certain privileged members are allowed to create certain content types.
Note
This behavior differs from Archetypes behavior where each content type was automatically assigned a permission for controlling its creation.
Create a permission with collective.autopermission in configure.zcml
<include package="collective.autopermission" />
<permission id="yourcompany.app.AddSuperContent" title="yourcompany.app: Add Super Content" />
Make sure that this permission becomes available on your site by adding the following to rolemap.xml
<?xml version="1.0"?>
<rolemap>
<permissions>
<permission
name="yourcompany.app: Add Super Content"
acquire="True">
<role name="Manager" />
</permission>
</permissions>
</rolemap>
Add in your content type GenericSetup XML
<!-- add permission -->
<property name="add_permission">yourcompany.app.AddSuperContent</property>
Reinstall your add-on.
Confirm that the new permission appears on the Security tab in the ZMI root.
Dexterity relies on ++add++yourcontent.type.name traverser hook defined in Products/CMFCore/namespace.py.
It will look up a multi-adapter using this expression:
if ti is not None:
add_view = queryMultiAdapter((self.context, self.request, ti),
name=ti.factory)
if add_view is None:
add_view = queryMultiAdapter((self.context, self.request, ti))
The name parameter is the portal_types id of your content type.
You can register such an adapter in configure.zcml
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
>
<adapter
for="Products.CMFCore.interfaces.IFolderish
Products.CMFDefault.interfaces.ICMFDefaultSkin
plone.dexterity.interfaces.IDexterityFTI"
provides="zope.publisher.interfaces.browser.IBrowserPage"
factory=".flexicontent.AddView"
name="your.app.flexiblecontent"
/>
</configure>
Warning
Overriding add_view_expr or add_view_expr_object in Dexterity factory type information, so that they directly link to a view provided, is not possible. You can manually type Add view link in portal_types, but setting it through GenericSetup installer code is not possible.
Then you can inherit from the proper plone.dexterity base classes:
from plone.dexterity.browser.add import DefaultAddForm, DefaultAddView
class AddForm(DefaultAddForm):
def update(self):
DefaultAddForm.update(self)
def updateWidgets(self):
""" """
# Some custom code here
def getBlockPlanJSON():
return getBlockPlanJSON()
class AddView(DefaultAddView):
form = AddForm
See also:
Example:
from five import grok
from plone.directives import dexterity
class EditForm(dexterity.EditForm):
grok.context(IFlexibleContent)
def updateWidgets(self):
""" """
dexterity.EditForm.updateWidgets(self)
# XXX: customize widgets here
The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed.
For basic information about updating this manual and Sphinx format please see Writing and updating the manual guide.