[ZDP] A first shot at a Zope Quickstart (part 1)

Rik Hoekstra rik.hoekstra@inghist.nl
Mon, 22 May 2000 22:40:14 +0200


Below follows a first shot at a Zope Quickstart. It is only the first part
and in rather clumsy plain text. Further on there should follow (many) other
parts: DTML, Connecting a database in Zope etc etc (not security). I have
deliberately kept everything very lightweight. There are no links in the
document at the moment, but there should be plenty. There should also be a
tight integration with the Tutorial.

Please, please, please let me know what you think

please

Rik


P.S. Questions:
Should this go into the ZDP Wiki.
Should I start a Quickstart project/task.
(How) Do we integrate this with ZBook?


----------------------------------

Zope Quickstart (part 1)


What is Zope

Let's start with the official short explanation, taken from the Zope web
site <URL: http://www.zope.org>:

Zope is the leading Open Source web application server. Zope enables teams
to collaborate in the creation and management of dynamic web-based business
applications such as intranets and portals. Zope makes it easy to build
features such as site search, news, personalization, and e-commerce into
your web applications.

Now this is a quite a bit especially with regards to promises, but the first
sentence is the most important. As an application platform you can use Zope
to build web applications, that is, interactive and dynamic web sites. This
means it does not only present static HTML pages to your users, but also 1)
make them interact with your site and 2) enables you to easily present data
from databases and other data sources in an HTML form (or other forms for
that matter). In this way a web application platform resembles cgi and other
scripting techniques in use on the web. As a framework, however, it is much
more structured.

Zope consists of several components which intimately work together to
provide a coherent and consistent whole. It is designed for the web from
scratch and it will cater for most common web needs, which are all present
in the quote from the Zope site.

You can use Zope from a host of different platforms, including Linux,
Windows NT, 95, 98, 2000, and most major Unix varieties and even from BeOS.


What Zope is good for

Whether you should use Zope, depends on you needs. If you want a flexible,
well thought out platform for your web application, you should definitely
take a look at Zope. If you want a flashy looking, easy to start (but
perhaps not so easy to maintain) product, if you care less about (initial)
cost and if you do not want to spend some time learning - Zope may not be
for you. For example: your current web site depends completely on Microsoft
products and you have a lot of time and money invested and you do not have a
new challenge in front of you - why change?

If you check out Zope, be prepared to spend some time learning. Not that it
is hard to start a simple web site in Zope. If you have a set of HTML pages
that you want to put into Zope, it will take you a half hour in a simple
Zope setup to get it up and running. This may be a good starting point, but
it cant't be more than a starting point, as Zope is for dynamic sites. If
you only have static pages to serve, you may be better off with a
specialized web server (like Apache). If you have dynamic content (and who
wants to be static rather than dynamic?) read on.

There is more to Zope than just this. Zope is an advanced platform, and it
is **well structured**. Therefore, it works best with a well-structured web
application. So you should be prepared to do some thinking about the
structure of your site. This *will* pay off in term of maintainability and
ease of extending.


Using Zope alongside another Web techniques

You may already be considering using Zope, but you already have considerable
effort put into another tool for your site, for instance straight cgi, php
or asp. Zope integrates well with any webserver able to run cgi. This means
you can continue to use your old scripts side by side with Zope. (However it
is not unlikely that once you get the knack of Zope you'll want to migrate
all your major Web scripting applications - you have been warned). How to
make them work together, will depend mostly on what you actually *are* using
right now, so please read the specific sections for that information.
[links]


Zope Requirements

If you consider using Zope, there may be a number of questions related to
cost, requirements in hard and software.
Zope is freely available from the Zope site http://www.zope.org. Zope is an
open source product.
The latest version is indicated on the downloading page. It depends on the
platform you're running on what version you will have to download [links].
There are binary versions for Win32 and for Linux [other?]. You can always
download a source release if you want to build the package yourself. The
development version of Zope is available from CVS [link].
Zope is platform independent. This means that you can develop in Zope on one
platform (say Windows 95) and have a production machine on a very different
one (say

For Zope, you will need relatively modest hardware. Digital Creations (who
created Zope) set out to have Zope run on a hardware configuration of less
than $ 1000. Zope.org *is* running on such a configuration.

You may use Zope for free, but you are asked to put the Zope attribution
buttion on your homepage or somewhere most appropriate on your site.


Setting up Zope

After you've downloaded the package, the setup procedure you'll have to
follow depends on the platform you're working on and of questions whether
you want Zope to integrate with existing webservers and so on.[links]

In a very generalized setup walkthrough you'll have to:
1) ensure you are running with the proper permissions on your system
2) unpack or execute (Windows) the distribution
3) Perhaps/probably change some parameters for running Zope
4) Set a superuser name/password combination
5) Startup Zope.

In a typical Win32 setup session you could be up and running in 20 minutes -
if you have a reasonable connection to the web (but the Zope download is
modest). In Linux ... [XXX complete]

Zope will run on its own, but it has very good possibilities for integration
with existing webservers. To test your first setup with Zope and to check it
is running well, you probably are best off by setting up Zope on its own. In
this way you will know if something has gone wrong with Zope at setup time.
Afterwards you can then start integrating Zope with existing components,
like external webservers.

If installation has gone well, you can test it by firing up your web browser
and point it to http://localhost:<zopeport>, in which <zopeport> should be
replaced by the port you installed Zope under (see the specific installing
information). You should get a welcome page for you Zope installation. You
can test whether you can authenticate with Zope by clicking the link
pointing to the  management screens.

Getting Started

So now you have Zope running, now what. There are several options for
getting started with Zope. If you just want experience the look and feel of
Zope, the Tutorial [link] is your best bet [short explanation]. To be sure,
the tutorial is probably your best bet anyway, but if you downloaded Zope to
get some things done, here are some pointers.

[links]

Some Zope principles

To get started, you'll need to know something about Zope's architecture if
you do not want to get hopelessly confused.

First: Zope is about object publishing. While this may sound technical
(because it is), this should not deter you from using the system, as you
will never need to use the objects directly. If you have never programmed
much, or never programmed in an object oriented language, this is not the
place to introduce you to it [link]
Suffice it here to state that objects are "self-contained" pieces of
software with their own properties and behaviour. In Zope, they replace
files. They live in the Zope database (well, they might live somewhere else,
but that is not important now.) Superficially seen, they mimic the behaviour
of a filesystem: there are objects that mimic folders and there are objects
that mimic all types of documents (images, files, html files etcetera).
Folder-like (called "folderish" objects in "Zopish") may contain other
objects. They are object managers. As you can also add other folders to
folder objects, in this way you can build object hierarchies.

This implies that if you made a website in Zope (using the tutorial for
example), and want to inspect what you've made "by hand", you will not be
able to find it. The Zope database (*ZODB* or *Zope Object Database*) is
called data.fs. It is in the <zopehome>/var directory. The behaviour of the
Zope objects are defined in so-called *methods* in standard OO (=Object
Oriented [programming]) terminology. These methods can either be called
directly through the Web, using Zope of course, or they are called inside
the Zope framework. The properties of the Zope objects are also called
properties.
How all this fits together will not concern us here - if you are interested
[links]

Second: Zope is managed through the web. In effect this means: 1) your
objects are tanslated to urls if you call zope. In this way, if you have an
object hierarchy consisting of a few folders and some other objects like so:

/root
  /folder1
    file1
    image
    file2
    /folder2
      file3
      file4

If your site is called www.zopesite.org, the url of file1 will be
http://zopesite/folder1/file1. The url of folder2 will be
http://zopesite/folder1/folder2 and the url of file4 will be
http://zopesite/folder1/folder2/file3. Zope has a number of tricks to change
these representations, but that is much too advanced stuff to treat here
[links]
2)You can create and modify objects using the management interface that is
built into Zope. We already had a glance at it above.

You'll need an appropriate id and password to access it. If everything went
well, you set these when you installed Zope (see above). The ZContent
management Guide [link] covers the use of the management interface in much
more detail than we could here. Nonetheless here follows a high-level
overview for the impatient.

Overview of the Zope Management Interface

[screenshot, there should be other screenshots above as well]
The web management interface consists of a few different sections. At a
first glance, you will see the different frames that together make up a
Mac/Windows Explorer-like interface. The left frame is used for navigation,
the right frame for editing etcetera. The right frame has tabs displayed at
the top. Behind the tabs are different views of aspects of the current
object, or they indicate that different actions useful in the context of the
selected object may be performed there. All this is pretty standard user
interface stuff.

Left Frame

The left frame of the management interface has basically 2 different
sections: the Control Panel and the tree of folders and other items. Once
again, please remember that these *look* like folders, files and documents,
but in reality they are object representations - not real folders or files.
The Control Panel object contains the interface to a few basic operations in
Zope:
o database management (of the ZODB database)
o other basic management actions
o product managment

Products are Zope components. They may be added to and removed from the
system. After they have been installed they usually become objects that are
addable through the management interface.

Right Frame

Adding, modifying and deleting objects is done in the right frame in the
management interface. To get technical: in effect this is done by calling
*manage* methods in Zope, but that won't concern us here [links]
The available objects that are useful in a certain context are shown in the
drop down list under the contents tab. Basic object types are:
o Folder
o Images and Files
o DTML Document and DTML Method
o User Folder

Deleting and modifying objects is rather straightforward. They will not be
covered here.

Adding Objects

There are many more objects and the list may be extended by adding Products.
Adding an object normally includes the following sequence of actions:

1. In the management interface you click the object to be added in the drop
down list
2. you get a form with some fields to fill in
3. after the form is submitted the object is created
4. you are returned to the management interface (sometimes through a dialog
that tells you the action has succeeded)

While the basic object types more or less speak for themselves, I shall
outline their function here:

o A folder contains other objects. It has its own properties, that may be
added under the properties tab
o A User Folder contains Users. Users are necessary for security. Security
in Zope is a sophisticated issue; it will *not* be treated in this cursory
introduction
o Images and Files are what they seem. Zope is able to sniff their type by
their extension. They have their own properties
o DTML Methods and DTML Documents are very much alike. They are the basic
objects that contain content. Content may be XML or plain text, but it
usually is a mixture of HTML and DTML. DTML stands for Document Template
Markup Language, which sounds more like XML than it is at the moment. We'll
return to DTML below, suffice it here to state that it is used for putting
logic into Zope.
The differences between DTML Documents and DTML Methods are slight, but
important. The differences boil down to DTML Documents being separate
objects and DTML Methods only methods of the containing object, that is
snippets that may contain bits of static content and logic (so I lied when I
wrote that they were objects).
This has implications for their use: DTML Methods should only be used for
logic and modular pieces of information: for DTML and for some HTML
snippets. DTML Documents (should) contain content with some (as little as
possible) DTML. As a rule of thumb, the DTML in DTML Documents should only
be used for including DTML Methods, that modify the content of the DTML
Document.

For instance, if you have a header to be used in all pages at your site, it
should be a DTML method. It may be included into a DTML Document with DTML,
like this:

ExmplHeader (this is a DTML Method):

<html>
<head><title><dtml-var title></title></head>
<body>
<h1><dtml-var title></h1>

ExmplDocument:

<dtml-var ExmplHeader>
<p>all sorts of interesting content</p>
<dtml-var ExmplFooter>

(the footer is not included here)