jump to content

Satheesh Babu
2001/03/30

I develop my site using Zope. It is a very good application server. However, Zope is also a terrific content management tool. In this article, I explain how to make a static mirror of your dynamic Zope site, which can then be served by Apache/IIS or other dumb servers. This is useful, if you want to speed up things, or if your hosting provided cannot run Zope on their servers.

Necessary Software

Preparing Content in Zope

Please see Zope's content management guide for general idea on Zope. For most static sites, you probably have only HTML documents, images and other binary files.

Let us see what are the Zope equivalents to these.

That means, if you want to add an HTML Document to your site, you choose a DTML Document from Zope's Available Select type to add... drop down list. Similarly for Image and File. However, what is the big deal in saving files in Zope, as opposed to saving files in your file system? Especially so when most of the editing you do in Zope seems to be through HTML forms!

Enter DTML Methods

To make a consistent looking site you can use Zope's equivalent of server side include files called DTML Methods. This is a very unfair analogy! DTML Methods are far more superior than silly include files! Why? One word - Acquisition. No, this is not related to Spanish history. In simple terms, it means that when you call or refer to a DTML method (you refer to it as ) Zope will see if that method is there in the current folder. If there, it will use that. If not, it will go to the parent folder of the current folder and then check there. And so on. So, Acquisition will get you the nearest one available. This is so cool, because for the whole site spanning multiple folders, you can have just one set of include files at the root folder! Compare this with normal include files, which will have to be replicated everywhere and probably have to be referenced using absolute URLs.

Important note! This explanation of Zope and DTML methods is a very unfair and simplistic one. DTML methods and DTML (Zope's template language) are very powerful programming tools. For more information, check the documentation section at Zope.org.

What about the previous article?

My previous article about using Zope for these kind of things covered some ground. However, the scripts shown here are far better and actually mirror a Zope site!

On a side note, every one can scream WGET at me! However, I didn't find it that good for my purposes.

Components

0_folderfile_listing

I called it 0_folderfile_listing because I usually name all DTML methods as 0_blah_blah. This shows them up at the top. You must create this DTML method at the top most level in Zope's hierarchy.
View the code
The code is also there at the end of the script given below. You can copy the last 3 lines and paste it into the DTML method. Remove the ## at the beginning of each line. You should not format it to beautify it!

zopemir.py - Python Script

You can run this script with the same Python that comes with Zope. See the bin folder under your Zope installation. That has a Python interpreter. Essentially, this is a rewrite of the ftpmirror.py script that is included in the standard Python distribution. You can edit the script and search for tux. That is the name of my Zope server. Change it with your server name.

Color coded python code

How to use this?

Well, after you have saved the script as say zopemir.py, you can run it as


python zopemir.py -v -r http://myzopesite /

It will mirror your entire Zope site to the current folder. For explanation on options, see the code.

Notes
Updated on 10/18/01 - zopemir.py has one more feature and some more comments.

References

  1. www.zope.org
  2. www.python.org
  3. rsync.samba.org
  4. How-To: Mirroring Zope with WGET
  5. How-To: static DTML documents from database records