Plone 3 Products Development Cookbook
上QQ阅读APP看书,第一时间看更新

Installing Plone on Linux

Now that we have a valid Python version, we can install Plone.

Note

There is an alternate and very handy method to install Plone on Linux (and Mac and Windows) called Unified Installer. It is a bundle that installs not only Zope and Plone, but also Python and other necessary packages. If you want to try it, go to http://plone.org/download and download the version of your choice.

Getting ready

ZopeSkel is a Python package that provides development templates for Zope and Plone. It will help us at several different stages of our projects. We will use it here to create a buildout environment. First, we must be sure we have it properly installed:

  1. Activate your just installed Python 2.4 (or whatever version you have installed) virtualenv:
    $ source ~/libexec/python2.4/bin/activate
    
  2. Install ZopeSkel:
    (python2.4)$ easy_install-2.4 ZopeSkel
    
  3. If you already have it, check for the latest version by running:
    (python2.4)$ easy_install-2.4 -U ZopeSkel
    

How to do it…

  1. Create a buildout with paster: Once you have the correct ZopeSkel version installed for your Python environment, run the following command to create a Zope/Plone buildout:
    (python2.4)$ paster create -t plone3_buildout
    

    Note

    Starting with ZopeSkel 2.15, when creating buildout environments with paster, you will see a warning message informing you that Unified Installer is the best option for installations and paster is just for experts. Although Unified Installer is great and incredibly useful, we think Plone developers should know how to create a Plone environment from scratch and this is the way to do it.

  2. Run the bootstrap process:
    (python2.4) $ cd pox
    (python2.4) $ python bootstrap.py
    
    How to do it…
  3. Edit the buildout.cfg file and locate the eggs parameter in the main [buildout] section and add PIL (Python Imaging Library) as a package to be downloaded and installed during buildout.
    [buildout]
    ...
    eggs = 
     PIL
    ....
  4. Buildout your Zope instance: This last step is to run the buildout process.
    (python2.4) $ ./bin/buildout
    

How it works…

Executing Step 1 will start a wizard to help with the creation of the buildout.cfg, we need. For each of the following options, provide these values:

A new folder named pox (the project name we used in the first option) with a basic directory structure and two very important files—bootstrap.py and buildout.cfg— will have been created.

In Step 2, we run the bootstrap process to complete the directory structure and generate the executable buildout file.

Let’s see what buildout.cfg looks like after Step 3, where we added PIL in the eggs parameter:

[buildout]
parts =
    zope2
    productdistros
    instance
    zopepy

This is a four-part buildout. Each part will be run consecutively.

extends = http://dist.plone.org/release/3.3.4/versions.cfg
versions = versions

Egg version numbers will be fixed (or pinned) to the ones listed in the URL above. Note that the URL is set according to the release number you have chosen when you ran the paster command before.

find-links =
    http://dist.plone.org/release/3.3.4
    http://dist.plone.org/thirdparty

Downloaded and installed eggs should be fetched from these package index servers.

# Add additional eggs here
eggs =
 PIL

# Reference any eggs you are developing here, one per line
# e.g.: develop = src/my.package
develop =

We will start using the eggs and develop parameters in the next chapter as we begin adding packages to our Zope instance. Meanwhile, we will need Python Imaging Library (PIL).

[zope2]
# For more information on this step and configuration options: 
# http://pypi.python.org/pypi/plone.recipe.zope2install
recipe = plone.recipe.zope2install
fake-zope-eggs = true
url = ${versions:zope2-url}

A recipe for Zope 2 installation:

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

A special recipe to download and install old-style Zope products (not released as eggs):

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

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

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

These are several configuration settings for the Zope instance that will be created during the buildout process.

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

zopepy is a Python interpreter with a sys.path variable full of the downloaded eggs and packages available at the instance's /lib/python folder. This is particularly useful to check if every package is available as expected.

The last step will take longer to execute than the previous steps, as it will download all the eggs listed in the buildout.cfg file above and all their dependencies (at the time of writing, Plone 3.3.4 has 74 direct dependencies).

This buildout executes the four parts explicitly mentioned in the parts definition at the top of the file:

  • [zope2]: Its plone.recipe.zope2install recipe downloads and installs the Zope 2 version mentioned in ${versions:zope2-url}. You can find this parameter at http://dist.plone.org/release/3.3.4/versions.cfg, the URL of the extends parameter.
  • [productdistros]: It executes with its plone.recipe.distros recipe. In our example, we don’t have any urls listed, so it won’t process anything here.

    Note

    Note that there are very few old-style Zope products that are really worth installing in a modern instance. Being old-style means being unmaintained, so use them carefully.

  • [instance]: It uses a plone.recipe.zope2instance recipe to install a Zope instance. We can see here most of the options we set when we ran the paster command before.
  • [zopepy]: Using zc.recipe.egg will create a Python interpreter named zopepy with all the eggs found in the instance section (check ${instance:eggs}) in the sys.path variable.

See also

  • Installing Python on Linux
  • Installing and configuring an egg repository
  • Writing a production buildout