You are not logged in Log in Join
You are here: Home » Members » glpb » Zope From Absolute Zero

Log in
Name

Password

 

Institutional Web Management Workshop 2001: Organising Chaos

Parallel Session C4: Zope From Absolute Zero

Leader: Paul Browning, University of Bristol
Venue: Computer Room 313, Peter Froggatt Centre
Time: 4.00-5.30 on Tuesday 26 June 2001

Aims & Objectives

  1. To download, install and configure "core" Zope as an NT service
  2. To gain familiarity with the Zope Management Interface (ZMI)
  3. To author a Web page
  4. To download and install additional Zope "Products" so as to extend the core
  5. To build a simple Web application that can browse and edit database records

Prerequisites

Participants should find the tasks straightforward if:
  1. They are familiar with with Windows NT
  2. They are familiar with Web browsers
  3. They are familiar with ftp/http downloads/uploads
  4. They are familiar with WinZip
  5. They have used InstallShield-type application packages on Windows
  6. They are able to author an elementary HTML page in simple text editor
  7. They have a passing familiarity with Access
  8. They have a passing familiarity with SQL


These instructions have been written for a team of two people to work through. However, the exercise can easily be undertaken solo - whenever you see reference to <partner PC IP number or name> just use localhost instead.

Tasks

1. Form a team of two

Pair up with someone so that you are sitting at adjacent PCs - you will take turns at being "client" and "server". Ideally you and your partner will have the skills to cover all the prerequisite bases above.
  1. Login to your PCs.
  2. Open this document (http://www.zope.org/Members/glpb/zfaz.htm) in a browser and bookmark it (the links will be indispensable).
  3. Determine the IP name/numbers of your PCs. Write them down in the table below. This Web utility may help.
Partner Partner
name
IP name IP number Initial manager 
username/password
Superuser 
username/password
Partner
username/password
A       zope/ root/ partner/
B       zope/ root/ partner/


When setting passwords for the zope, root and partner users on your respective PCs it is best to keep them different in all cases if you are not to be caught out by the Web's simple-minded authentication mechanism.

2. Download, install and configure "core" Zope as an NT service

  1. At the time of writing Zope 2.3.2 was the latest stable release. Zope is available as a Windows installer package (it is also available in various Unix flavours and as source code) that will give you Python, Zope and Zope as an NT service it one hit. Download and save the installer to a temporary directory on a local disk.
  2. You should now have an application file at C:\TEMP\ZOPE-2_3_2-WIN32-X86.EXE or similar. Launch it.
  3. During the installation you will need to do three things:
    1. Set a Site Name
    2. Set a username (use "zope") and password for the initial manager (write it down in the table above)
    3. Select "Run as a win32 service"
  4. During the installation three things are happening:
    1. The core Zope files and Python are copied to (typically) C:\Program Files\<Site Name>
    2. Python compiles the Zope modules
    3. ZServer (the http/ftp server) is started (if you selected that you wanted Zope installed as an NT service)

3. Gain familiarity with the Zope Management Interface (ZMI)

  1. If all is well you should able to browse to http://localhost:8080. By default ZServer provides an http service on port 8080 and an ftp service on port 8021.
  2. Now browse to http://localhost:8080/manage. Enter the username and password you provided for the initial manager.
  3. Explore the  NT Explorer-like ZMI.
  4. Go back to the "root" of the file tree (you should see "Folder at  /" in the RHS ZMI frame) and open the folder acl_users.
  5. Add a true superuser called "root" with the role "Manager" and set the password (write it down in the table above).
  6. Quit your browser (which effectively logs you out of Zope).
  7. Re-launch your browser and go again to http://localhost:8080/manage. This time enter the username and password you set for the user root.
  8. Create a folder object with the id "partner" in the root folder by using the pull-down Add menu (check "Create public interface" and "Create user folder ").
  9. Make your partner manager of  the "partner" folder by creating a user called partner with the appropriate role in the acl_user folder (inside the "partner" folder). Make a note of the password in the table above.
  10. Browse to http://<partner PC IP number or name>:8080/partner
  11. Browse to http://<partner PC IP number or name>:8080/partner/manage. You should have to authenticate as partner. Can you access the root folder as partner?

4. Author a Web page

  1. Open the DTML Document object index_html (via the ZMI) that is in the partner folder (on your partner's PC not your PC).
  2. Make some changes and save them.
  3. Re-load this page - note that http://<your partner's PC IP number or name>:8080/partner and http://<partner PC IP number or name>:8080/partner/index_html point to the same thing (i.e. index_html is analagous to index.html or Welcome.htm on Apache - it is the default "public interface").

  4. (By this stage you may have recognised the utility of having two different browsers - not just windows in the same browser - open. One browser (e.g. Netscape) can show the anonymous (or at least less priveleged) user view; the other browser (e.g. IE) shows the superuser view. The behaviour of Web applications can very much depend on who is using them and it is important not to loose track of the user context. Authentication credentials are stored on a browser session basis and you can't easily loose them unless you login as another user or you quit your browser and login in again. This is a general Web problem not a Zope problem!)
     

  5. There are countless ways to edit content in Zope - you are not restricted to the textarea boxes of the ZMI forms. Because Zope supports many protocols you have many choices (this list is by no means exhaustive):

  6.  
    Protocol Editor
    http Netscape Composer, Amaya
    ftp HomeSite, emacs, BBedit
    WebDAV GoLive, anything via Web Folders

    Save this page as an HTML file on your PC. Edit it using Notepad. Upload into into the partner folder by using the Add menu to create a new DTML Document.
     

  7. If you're feeling adventurous (and masochistic) also try uploading the same file (but rename it first) via command line ftp from the MS-DOS prompt - the incantation is:

  8.  
      ftp
      open <partner PC IP number or name> 8021


    and then the usual sort of commands.



If you've got this far then well done!

You've essentially reproduced the functionality of Apache + file system or IIS + file system - except the "file system" is an object database that behaves like a file system to http and ftp clients. The object database (ZODB) is a single file ("Data.fs") that sits inside the Zope var directory. (Note: there is a Zope Product called Local FS that allows you to point at content in your "real" file system - you don't have to put all your content in the ZODB.)

Although we haven't demonstrated it yet, you have in fact also reproduced the functionality of Apache + Perl + file system or IIS + ASP + file system. Zope is a programmable Web application server straight out of the box. You can do CGI-like stuff straight away if you wish. However, there are quicker routes to building Zope applications - this is where "Products" come in.


5. Download and install ZODBCDA, Znolk and a Hotfix

  1. Download and save the Zope ODBC Database Adapter to a temporary directory on a local disk.
  2. Download and save the Znolk SQL Wizard to a temporary directory on a local disk.
  3. Download and save the latest Zope Hotfix to a temporary directory on a local disk (this addresses a security issue with Zope 2.3.2).
  4. For each of these "Products":
    1. Double-click on the .tgz archive to launch WinZip
    2. Extract the files in the archive into the "root" of your Zope installation (e.g. C:\Program Files\<Site Name>) on your local hard disk. This way the Products will be correctly installed in the lib\python\Products directory of your Zope installation.
  5. As the "root" user (and from the root folder in the ZMI) open the Control Panel. Click the Restart button.
  6. After a few seconds Zope should restart and you can check to see if the new Products have been successfully installed by going to the Product Management screen in the Control Panel.
  7. If Zope fails to restart then it can be started manually via the Windows NT Services Control Panel (look for a service which is called <Site Name>).

6. Make and test an ODBC database connection

  1. Download and save the Access database zfaz.mbd to a temporary directory on a local disk.
  2. From Windows NT (not the the ZMI) select Settings > Control Panel > ODBC Data Sources :
    1. Select the System DSN tab
    2. Click the Add button
    3. Select Microsoft Access driver
    4. Click Finish
    5. Enter a Data Source Name "zfaz"
    6. Navigate to your local copy of zfaz.mdb
  3. From the ZMI open the partner folder (providing your partner has completed all of the above).
  4. From the Add menu create an instance of a "Z ODBC Database Connection".
  5. Give it the id "zfaz", select the ODBC Data Source "zfaz" from the scroll box and click Add.
  6. From the partner folder open the zfaz object and select the Browse tab.
  7. If you can see a table called "unitcat" you're in business. Click the "+" symbol to reveal a list of fields in the unitcat table.

7. Use Znolk SQL wizard to build a simple Web application

  1. From the partner folder select "Znolk SQL Wizard" from the Add menu.
  2. Confirm that your Connection id is "zfaz" - click Add.
  3. Select table "unitcat" - click Next.
  4. Check Primary Key for the Column "code"; select the Control Textarea for the Column "desc" - click Next.
  5. Accept all the defaults - click Finish Wizard.
  6. Note the collection of DTML Documents and SQL Methods that have been generated in the partner folder.
  7. Browse to http://<partner PC IP number or name>:8080/partner/UnitcatBrowseReport
  8. Experiment with the Web application. There are two show-stopping bugs (related to the use of a Memo field for the column "desc").
  9. Fix the bugs by editing UnitcatInsertMethod and UnitcatUpdateMethod - in each case replace "desc" by "[desc]" (and remember to Save Changes).
  10. Try the Web application again - you can now browse, edit, create and delete records!
  11. Consider how you might improve the usability of the application.


Very well done if you got this far!

We have now seen how Zope is modular and can be extended by the use of Products. We have also seen a common mode of working - Zope Products provide "wizards" to build a vanilla shell for your application (very quickly) and then you customise it as required.


Additional resources

Zope Eurasian Links

Gotchas

  1. Proxy cache?
  2. Sufficient NT privileges?
  3. What if www.zope.org goes down?
  4. Win 95/98 - tweaking C:\WINDOWS\HOSTS
  5. Browser versions:
    • IE5.0 will not display all of the ZMI
    • Some versions of Netscape seem to run the ZMI very slowly