You are not logged in Log in Join
You are here: Home » Members » 4AM Productions (Evan Simpson) » Make your life easier with INSTANCE_HOME

Log in
Name

Password

 

Make your life easier with INSTANCE_HOME

A default Zope installation places your site data within the same subdirectory as the Zope software itself, and encourages you to add Products to the same directory as the ones which came with Zope.

It doesn't have to be this way, though. You can easily place all of your site's data, and the Products it uses, in a separate location.

Why would I want to do that?

  • you can keep "standard" Zope Products separate from ones you have installed. You can make some Products and Extensions shared, and some site- specific.
  • you can run multiple, independent Zope sites from the same installation of Zope.
  • you can keep multiple versions of Zope around, and easily change the version used by a site.
  • you can upgrade Zope by just installing the new version.

How does it work?

Zope looks for an environment variable called INSTANCE_HOME. If it is found, its value is the location of var, import, and access. It can also have a custom_zodb.py module.

Both the INSTANCE_HOME location and the Zope installation can have Products and Extensions. The INSTANCE_HOME is searched first.

So what do I do?

  1. Create a directory for your site
  2. Place the var and Extensions directories and the access file for the site in the site directory. If you are starting from scratch, you can make empty directories and create access with the zpasswd.py utility.
  3. Create an import directory and a Products directory. Install or copy products you use that are not distributed with Zope into this Products.
  4. (*nix only) If you want to share some Products among all sites, but still keep them independent of your Zope installation, you can create a Shared_Products directory for them somewhere, then symlink them into the Zope Products directory.
  5. If you follow Jim Cain's excellent howto, you can skip the following steps.
  6. Copy start and stop to the site directory.
  7. (*nix only) Edit start to look something like the following (the lines defining and exporting variables are the important ones):
        #! /bin/sh
        reldir=`dirname $0`
        INSTANCE_HOME=`cd $reldir; pwd`
        export INSTANCE_HOME
        exec /usr/bin/python2.1 \
             /usr/local/Zope2.4.3/z2.py \
             -D "$@"
    
  8. (Win32 only) Edit start.bat using Notepad or your favorite text editor to look something like the following (using your own file paths, of course):
        "C:\Zope\bin\python.exe" "C:\Zope\z2.py" -D %1 %2 %3 %4 %5 %6 %7 %8 %9 INSTANCE_HOME="C:\MyWebSite"
    
  9. Edit stop so that the path it uses leads to the site's var, not the Zope installation.

What now?

Use the start and stop scripts in the site directory to control that site. You can install a new version of Zope simply by replacing your current installation. You can install different versions of Zope in different directories, and switch among them by changing the path to Zope in your start script.