A contenttype template in ZopeSkel's localcommands
Here's what the contenttype template will do for you after you've answered some questions:
- Define a new Add Permission the product's config.py
- Define an interface for the content type you're creating.
- Create a content type class, in a subdirectory named content/
- Register this content type class in content/configure.zcml
- Register the new content type in the factorytool, by adding to profiles/default/factorytool.xml
- Register basic permissions for the new content types, by adding to profiles/default/rolemap.xml
- Register the content type with portal_types by adding to profiles/default/types.xml
- Add a new file with configuration information in profiles/default/types/.
Here's an example on how to use the template. You'll need mustap's branch of ZopeSkel for this to work:
Begin by creating a new product based on ZopeSkel's the Archetype template:
$ paster create -t archetype
Selected and implied templates:
ZopeSkel#basic_namespace A project with a namespace package
ZopeSkel#plone A Plone project
ZopeSkel#archetype A Plone project that uses Archetypes
Enter project name: efod.test
Enter title (The title of the project) ['Plone Example']: Contenttype Example
Enter namespace_package (Namespace package (like plone)) ['plone']: efod
Enter package (The package contained namespace package (like example)) ['example']: test
Enter zope2product (Are you creating a Zope 2 Product?) [False]: True
Enter version (Version) ['0.1']:
Enter description (One-line description of the package) ['']:
Enter long_description (Multi-line description (in reST)) ['']:
Enter author (Author name) ['Plone Foundation']:
Enter author_email (Author email) ['firstname.lastname@example.org']:
Enter keywords (Space-separated keywords/tags) ['']:
Enter url (URL of homepage) ['http://svn.plone.org/svn/plone/plone.example']:
Enter license_name (License name) ['GPL']:
Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]:
Now go into the directory just created:
$ cd efod.test
$ paster addcontent contenttype
Enter contenttype_name (Content type name ) ['Example Type']:
Enter contenttype_description (Content type description ) ['Description of the Example Type']:
Enter folderish (True/False: Content type is Folderish ) [False]:
Enter global_allow (True/False: Globally addable ) [True]:
Enter allow_discussion (True/False: Allow discussion ) [False]:
Inserting from config.py_insert into /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/config.py
Recursing into content
Copying +content_class_filename+.py_tmpl to /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/content/exampletype.py
Inserting from configure.zcml_insert into /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/content/configure.zcml
Inserting from interfaces.py_insert into /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/interfaces.py
Recursing into profiles
Recursing into default
Inserting from factorytool.xml_insert into /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/profiles/default/factorytool.xml
Copying rolemap.xml_insert to /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/profiles/default/rolemap.xml
Recursing into types
Copying +types_xml_filename+.xml_tmpl to /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/profiles/default/types/Example_Type.xml
Inserting from types.xml_insert into /home/forsberg/dev/plone/mustaptest/src/efod.test/efod/test/profiles/default/types.xml
That's it! After registering the archetype product in your buildout and installing it in Plone, you'll be able to add new 'Example Type' content.
Of course, for your custom content type to be really useful, you'll have to edit it, adding new fields and modifying templates.
I am by no means a Plone guru, so some of the details in how this template constructs the new content type may be less than optimal. Please tell me if that's the case, and I'll see what I can
Depending on the answer to the "Folderish" question, the newly created content type will inherit either from Products.ATContentTypes.content.base, or from Products.ATContentTypes.content.folder.
The template will set up AnnotationStorage and bridge properties for the standard title and description fields.
The Manager role is given the add permission for the content type (in profiles/Default/rolemap.xml).
zope2.View is required to view the content, and cmf.ModifyPortalContent to edit.
The standard views auto-generated by Archetypes are used as a default. Perhaps generating a custom view class, with template, would
be more Plone3? On the other hand there's already another template for creating a view available.