Getting a Plone Instance Going

The first basic requirement for doing Plone development is of course to have a Plone instance running. This is covered in many other documentation resources, but I'll give a short introduction anyway.

  1. Get a modern Zope. Zope 2.8.x is recommended for Plone 2.1.x, but a Zope 2.7.x will probably do as well for most cases.

    If your operating system doesn't have any Zope in its package system, or if it's too old, download Zope from http://www.zope.org and install it at some prefix using the instructions provided with the package.

    In my case, my Linux distribution (currently Debian Sarge, although I'm very much thinking about switching to Ubuntu Linux) has a Zope 2.7.5 as a package. However, I've downloaded Zope 2.8.5 from http://www.zope.org and installed it under /opt/Zope.

  2. Create a Zope instance. This is done using the mkzopeinstance.py script. In my case, it's available as /opt/Zope/bin/mkzopeinstance.py.

    If you're using a Zope from your Linux distribution, mkzopeinstance.py is probably in your path when you run as root. It may have a slightly changed name - for example, the Zope 2.7.5 which is available in Debian sarge has a mkzope2.7instance.py, which I guess is to make it possible to have several Zope installations of different versions.

    Run mkzopeinstance.py and answer the questions. The first question is about where to create the files associated with the instance. On my Debian machines, I place instances under /var/lib/zope<version>/instance/<name> where <version> is 2.8 for Zope 2.8 instances, and <name> is a word describing what the instance's for. So, the instance driving this site is located under /var/lib/zope2.8/instance/efod.se. This directory will from here on be referred to as $INSTANCE_HOME.

    Give a username as well as a password for the initial administrative user. This is the superuser of the Zope instance, which will have permissions to do everything, so use a good password for instances which will be available from the internet.

  3. You now have a Zope instance, but it's not of much use yet. Continue by looking through the file $INSTANCE_HOME/etc/zope.conf. Take note of the port number, make sure effective-user is set to a user that exists but is not root, and that debug-mode is set to on. The latter is important during development, but should be changed for a production instance for performance reasons. Make sure the $INSTANCE_HOME/log and $INSTANCE_HOME/var directories are writable by the user set as effective-user, or you will get an error when starting Zope.

  4. In order to run Plone, you need to install a number of "Products" into the directory $INSTANCE_HOME/Products. Each product is, simply speaking, a collection of code, templates and other files, in it's own directory under $INSTANCE_HOME/Products. Plone consists of a number of Products, delivered in a tarball available from http://plone.org/products/plone. Download the tarball for the latest Plone and unpack it in a temporary location, then move all directories from the temporary location into $INSTANCE_HOME/Products.

    Don't move the Plone-x.y.z folder into the Products folder - move the directories under Plone-x.y.z into the Products folder.

  5. You've now equipped your Zope instance with the software needed for it to run Plone. It's now time to start the Zope instance. This is done either by running $INSTANCE_HOME/bin/runzope which will run your zope without going into the background, printing some debug information while running. This is good for development purposes. The instance can be stopped simply by pressing Ctrl-C.

    The other alternative is to run $INSTANCE_HOME/bin/zopectl start. This will start zope and detach it from the running terminal which is good for a production instance. This is also what should be run from a init script at system startup, if automatic startup of Zope is desired.

    Watch your Zope startup. When you see the message INFO Zope Ready to handle requests, Zope is, well, ready to handle requests :-)

  6. Connect to your Zope using a web browser. Zope will be available on the port you configured in $INSTANCE_HOME/etc/zope.conf in step 3. Type in http://localhost:<port> in your browser.

    You will be presented with a small page titled Zope Quick Start. There's really nothing interesting there except the link to the Zope Management Interface, commonly referred to as ZMI. Click on that link, and Zope will pop up a standard Authentication dialog asking for username and password. Provide the username and password that you gave to the mkzopeinstance.py script in step 2, and you will be presented with the ZMI, which is a rather complex page.

  7. Locate the selectbox in the upper right area of the ZMI, the one with an Add button to the right. Locate Plone Site in the selectbox, and select it. This will present you with a form with the fields Id, Title, and Description.

    Your plone site will be available in your Zope under a path. This path is determined by the value you enter into the Id field. I usually use the value "Plone", which means my Plone instance is available under http://localhost:<port>/Plone.

    Enter some value into the Id field and press the Add Plone Site Button. This will take some time, but when it's finished, your Plone site is ready for use.

  8. At this stage, I recommend that you restart your browser to get rid of the authentication used to access the ZMI. Then access your Plone site by visiting http://localhost:<port>/Plone. This should present you with a welcome page. You can login by using the same username and password as you used in step 6. (the one you gave to mkzopeinstance.py in step 2.).

  9. Your Plone instance is now ready for use!

Creating and Installing your own Product

To do successful Plone development, you need to create and use your own Product. This enables you to keep the code of your scripts and templates on disk, which means you can edit them with your favourite editor, and keep track of them with your favourite version control system. If you ask me, the alternative - editing through the web - is not an option.

(As a side note, the version control system that seems to be used by most Plone developers is Subversion.)

A Product consists of a number of files that needs to be there for Plone to recognize it as a product. The best way to make sure you get everything you need is to use DIY Plone Style, which is a skeleton product that you modify in order to get your own product. It will serve as a base for doing your own modifications to templates, scripts and CSS.

I Recommend that you read the documentation for DIY Plone Style, since it contains a lot of useful information on how to use the product, but here's the quick version:

  1. Download the tarball from http://plone.org/products/diyplonestyle. Unpack it into $INSTANCE_HOME/Products

  2. Run $INSTANCE_HOME/Products/DIYStyle/bin/generator.py --replace --productname MyProduct.

    This will reconfigure the DIYStyle Product into the product MyProduct (chooser your own name), so now you'll have a directory named $INSTANCE_HOME/Products/MyProduct.

  3. Restart Zope.

  4. Go into the Site Setup and then into Add/Remove Products. Select your product and press the install button.

    The will result in the logo up in the left corner being exchanged to another image (if not, make sure you force-reload your browser, in Firefox you do this by typing Skift-Ctrl-R). You're now using your own product.

The Product created by the generator.py contains only an empty CSS file, a new logo file and a file named base_properties.props, all of them in the subdirectory skins/myproduct_styles, but that's enough to get you started. Try editing the file named myproduct.css.dtml, adding some simple CSS. Here's an example:

.searchButton {
   display: none;
}

Add this after the line /* YOUR CSS RULES START HERE */ in myproduct.css.dtml, save, and reload your browser. The search button in the upper right corner should now disappear. (If it doesn't, make sure the debug-mode of your Zope instance is activated, since otherwise, you'll have to restart Zope for it to detect changes on the filesystem.)

More discussion on how to do simple changes will be found elsewhere in this document, in a yet to be written part :-).