Attention

This document was written for an old version of Plone, Plone 3, and was last updated 935 days ago.

To learn how to upgrade to the current version of Plone, read the upgrade manual.

Creating Plone instance

by Mikko Ohtamaa last modified Oct 30, 2009 09:56 AM
Plone instance should be set up in a way that Eclipse and PyDev can find all related Python files and their dependencies. This way we can take advantage of code completion, debug, inspect and other advanced IDE features.

Plone instance goes to the Python project folder created in Eclipse. Due to Eclipse metadata folders you need to create Eclipse project first and then apply a paster template over it - Eclipse is picky about importing external top level folders into projects. Eclipse project (folder) name and paster target folder name must match.

Creating Eclipse project
------------------------

`Create a new Python 2.4 project in Eclipse <http://plone.org/documentation/tutorial/developing-plone-with-eclipse/creating-eclipse-project>`_. In this example we call it *Plone-3.1*.

Buildout
-----------------

Buildout is a recommended Plone installation method, especially for development. Based on buildout.cfg file, buildout command automatically downloads and installs Zope, Plone and third part products. When products receive updates, they can be updated by running a single command.


Creating a buildout
----------------------

We use paster command to create Zope/Plone site skeleton which is used as a development instance.

`Paster installation instructions <http://plone.org/documentation/tutorial/buildout/prerequisites>`_ and `More about paster <http://plone.org/documentation/tutorial/buildout/creating-a-buildout-for-your-project>`_. Remember to use *python2.4* command on Linux instead of plain *python*.

Open your terminal/command line. Go to the *Eclipse workspace folder*. Type in command::

paster create -t plone3_buildout YOURPLONEINSTANCEPROJECTNAME

This way paster will place buildout files directly to your project folder. When paster asks questions, use default answers except for *debug_mode* and *verbose_security* which both should be turned on::

moo@hereford:~/workspace$ paster create -t plone3_buildout Plone-3.1
Selected and implied templates:
ZopeSkel#plone3_buildout A buildout for Plone 3 projects

Variables:
egg: Plone_3.1
package: plone31
project: Plone-3.1
Enter zope2_install (Path to Zope 2 installation; leave blank to fetch one) ['']:
Enter plone_products_install (Path to directory containing Plone products; leave blank to fetch one) ['']:
Enter zope_user (Zope root admin user) ['admin']:
Enter zope_password (Zope root admin password) ['']:
Enter http_port (HTTP port) [8080]:
Enter debug_mode (Should debug mode be "on" or "off"?) ['off']: on
Enter verbose_security (Should verbose security be "on" or "off"?) ['off']: on
Creating template plone3_buildout
Copying README.txt to ./Plone-3.1/README.txt
Copying bootstrap.py to ./Plone-3.1/bootstrap.py
Copying buildout.cfg_tmpl to ./Plone-3.1/buildout.cfg
Recursing into products
Creating ./Plone-3.1/products/
Copying README.txt to ./Plone-3.1/products/README.txt
Recursing into src
Creating ./Plone-3.1/src/
Copying README.txt to ./Plone-3.1/src/README.txt
Recursing into var
Creating ./Plone-3.1/var/
Copying README.txt to ./Plone-3.1/var/README.txt
-----------------------------------------------------------
Generation finished
You probably want to run python bootstrap.py and then edit
buildout.cfg before running bin/buildout -v

See README.txt for details
-----------------------------------------------------------


Settings up buildout.cfg
------------------------

Go back to Eclipse project view. Hit F5 or choose Plone 3.1 project root folder and right click -> Refresh to see new files.

Below is an example buildout.cfg file. It contains omelette product which creates easy to navigate folder structure for all files. Otherwise maintaining and reading source code from Python eggs must be do hard way by navigating through Python egg cache folders. Note that omelette references **must be removed on Windows**, since Windows doesn't support symlinks (NTFS junction points don't work in our use case) which is the method used by Omelette to create the easy view for Python source tree.

`More about Omelette <http://theploneblog.org/blog/archive/2008/03/10/collective-recipe-omelette-for-more-navigable-eggs>`_

Double click buildout.cfg in Eclipse to edit it. Paste in the following example and save the file. This is a sample buildout.cfg for Plone 3.1 containing omelette and plone.reload products.
::

[buildout]
parts =
plone
zope2
productdistros
instance
zopepy
omelette
zopeskel
pydev

extensions = buildout.eggtractor
tractor-src-directory = src
tractor-target-parts = instance

find-links =
http://dist.plone.org
http://download.zope.org/ppix/
http://download.zope.org/distribution/
http://effbot.org/downloads

eggs =
elementtree
plone.reload


develop =

[plone]
recipe = plone.recipe.plone>=3.1.1,<3.2dev

[zope2]
recipe = plone.recipe.zope2install
url = ${plone:zope2-url}

[productdistros]
recipe = plone.recipe.distros
urls =
nested-packages =
version-suffix-packages =

[instance]
recipe = plone.recipe.zope2instance
zope2-location = ${zope2:location}
user = admin:admin
http-address = 8080
debug-mode = on
verbose-security = on
eggs =
${buildout:eggs}
${plone:eggs}

# Needed for Python logging package
# Set this to "info" if you need less output or you don't use logging
event-log-level = debug

# If you want to register ZCML slugs for any packages, list them here.
# e.g. zcml = my.package my.other.package
zcml =
plone.reload

products =
${buildout:directory}/products
${productdistros:location}
${plone:products}

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
extra-paths = ${zope2:location}/lib/python
scripts = zopepy

[omelette]
recipe = collective.recipe.omelette
eggs = ${instance:eggs}
products =
${instance:products}

[zopeskel]
recipe = zc.recipe.egg
eggs =
PasteScript
ZopeSkel

# Automatically add eggs to PyDev project path
[pydev]
recipe = pb.recipes.pydev
pydevproject_path = ${buildout:directory}/.pydevproject
eggs = ${instance:eggs}
extra_paths = ${zope2:location}/lib/python/


Now go back to the terminal/command line, go to the project folder and type the following commands::

python2.4 bootstrap.py

bin/buildout

On Windows this is::

c:\Python2.4\python bootstrap.py

bin\buildout

This will download all required files and set-up Plone and Zope for you. Executing this might take a while, so now is a good moment to sip some cola.


Contribute

Something wrong or out of date? Anybody can edit or create a new article in the knowledge base. Simply create an account on this site, log in, and click the Edit button to contribute.