Creating a site, archetypes object and contenttypes with paster
How to make an instant plone site
As tested on ubuntu intrepid
Prerequisites:
sudo aptitude install build-essential python2.4-dev python2.4-setuptools
First off we need to tell python how to make a plone site:
sudo easy_install2.4 ZopeSkel
if that fails because your setuptools are too old, then try this:
wget http://peak.telecommunity.com/dist/ez_setup.py chmod +x ./ez_setup.py ./ez_setup.py
This will hopefully install the latest setuptools, after which you can retry ZopeSkel.
We can see the things that paster can build with:
rich@newsharkbait:~/anewplone/src$ paster create --list-templates Available templates: archetype: A Plone project that uses Archetypes basic_namespace: A project with a namespace package basic_package: A basic setuptools-enabled package basic_zope: A Zope project kss_plugin: A KSS plugin template nested_namespace: A project with two nested namespaces. paste_deploy: A web application deployed through paste.deploy plone: A Plone project plone2.5_buildout: A buildout for Plone 2.5 projects plone2.5_theme: A Theme for Plone 2.5 plone2_theme: A Theme Product for Plone 2.1 & Plone 2.5 plone3_buildout: A buildout for Plone 3 projects plone3_portlet: A Plone 3 portlet plone3_theme: A Theme for Plone 3.0 plone_app: A Plone App project plone_hosting: Plone hosting: buildout with ZEO and any Plone version plone_pas: A Plone PAS project recipe: A recipe project for zc.buildout silva_buildout: A buildout for Silva projects
So first we add a plone3_buildout
paster create -t plone3_buildout anewplone
It will give us some questions to answer, after which we will have a new plone buildout skeleton
then we:
rich@newsharkbait:~$ cd anewplone/
Then we can bootstrap the instance with the correct version of python:
rich@newsharkbait:~/anewplone$ python2.4 bootstrap.py Creating directory '/home/rich/anewplone/bin'. Creating directory '/home/rich/anewplone/parts'. Creating directory '/home/rich/anewplone/eggs'. Creating directory '/home/rich/anewplone/develop-eggs'. Generated script '/home/rich/anewplone/bin/buildout'.
which puts all the bits in place ready to perform the buildout. (at this point the python version you use will be the one that zope uses eventually, so choose wisely)
Next we edit buildout.cfg to make sure it's ok - if we answered the questions right when we made the buildout, it should be.
and finally to make a buildout we just
bin/buildout
This goes off and gets all the bits we need to make a zope instance with plone 3 installed. It can take a while the first time.
You can save the the bits for use in another buildout.
When all the stuff is downloaded it will proceed to build zope. When done start zope with
bin/instance fg
to check that it all works - eventually it says:
2008-12-12 12:43:32 INFO Zope Ready to handle requests
Now the clever bit. src/ is where we develop our new products so:
rich@newsharkbait:~/anewplone$ cd src rich@newsharkbait:~/anewplone/src$ 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: anewplone Variables: egg: anewplone package: anewplone project: anewplone Enter title (The title of the project) ['Plone Example']: My new plone site Enter namespace_package (Namespace package (like plone)) ['plone']: openia Enter package (The package contained namespace package (like example)) ['example']: newplonesiteexample Enter zope2product (Are you creating a Zope 2 Product?) [True]: Enter version (Version) ['1.0']: Enter description (One-line description of the package) ['']: Enter long_description (Multi-line description (in reST)) ['']: Enter author (Author name) ['Plone Foundation']: Openia Limited Enter author_email (Author email) ['plone-developers@lists.sourceforge.net']: support@openia.com Enter keywords (Space-separated keywords/tags) ['']: Enter url (URL of homepage) ['http://svn.plone.org/svn/plone/plone.example']: http://www.openia.com/ Enter license_name (License name) ['GPL']: Commercial Enter zip_safe (True/False: if the package can be distributed as a .zip file) [False]:
Then in our src/ directory we can see our "anewplone" egg, which although we asked for an "archetype" is actually a complete plone product too.
So now we go into our product directory
rich@newsharkbait:~/anewplone/src/$ cd anewplone/openia/newplonesiteexample
rich@newsharkbait:~/anewplone/src/anewplone/openia/newplonesiteexample$ paster addcontent -l
Available templates:
atschema: A handy AT schema builder
contenttype: A content type skeleton
portlet: A Plone 3 portlet
view: A browser view skeleton
zcmlmeta: A ZCML meta directive skeleton
This shows us which types are available here. For now we'll add an archetype contenttype
$ paster addcontent contenttype Enter contenttype_name (Content type name ) ['Example Type']: MyType Enter contenttype_description (Content type description ) ['Description of the Example Type']: An 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]:
rich@newsharkbait:~/anewplone/src/anewplone/openia/newplonesiteexample$ ls ./content/ configure.zcml __init__.py mytype.py
So we can see that the python file defining our type is there. If we look inside we will see it is perfectly formed with an empty schema.
So now:
paster addcontent atschema Enter content_class_filename ( What is the module (file)name of your content class? (.py is implied) ) ['exampletype']: mytype Enter field_name ( What would you like to name this field? ) ['field']: mystring Enter field_type ( What kind of field should I make for you? ) ['String']: Enter widget_type ( What kind of widget do you want to use? ) ['String']: Recursing into content Inserting from +content_class_filename+.py_insert into /home/rich/anewplone/src/anewplone/openia/newplonesiteexample/content/mytype.py
which gives us:
atapi.StringField(
name='mystring',
storage = atapi.AnnotationStorage(),
required=False,
#searchable=1,
#default='',
#schemata ='default',
widget=atapi.StringWidget(
label=_(u"mystring"),
description=_(u"Description of mystring"),
),
),
To use our new egg we add 2 lines to the buildout.
In the top [buildout] section we add to whatever is there:
eggs= [...] anewplone
and
develop =
[...]
src/anewplone
To use the archetype product we have to add something into the zcml section.
zcml = openia.newplonesiteexample
(notice the format is namespace.product)
Rebuild the buildout to develop your egg.
Restart zope and you should see your new archetype product.

