Lesson 8. Elvis Photo Archive, cont.

Zope cannot find the tutorial examples. You should install the tutorial examples before continuing. Choose "Zope Tutorial" from the product add list in the Zope management screen to install the examples.

If you have already installed the tutorial, you can either follow along manually, or reinstall the tutorial examples. Note: make sure that you have cookies turned on in your browser.

Now that we have a working photo archive, let's enhance it to handle submissions from site visitors.
  1. Click the photoForm document.

  2. Click the View tab to view it.

  3. Upload a picture (JPG, GIF, PNG or other graphics format supported by your browser.)

  4. Now return to the lesson8 folder in the Zope management screen using your browser's back button.

  5. Click the photoArchive folder to enter it.

Notice that there is now a new Image object in the folder. This image was created when you uploaded your photo.

Let's investigate how this works, and add the ability to give our uploaded photo a title.

  1. Click the photoForm document.

  2. Change the contents of the document to:

    <dtml-var standard_html_header>
    <h2><dtml-var title></h2>
    <p>Upload a picture to the Elvis Photo Archive.</p>
    <form action="photoAction" method="post"
    <p>Title: <input type="text" name="photo_title"></p>
    <p>File: <input type="file" name="file"></p>
    <input type="submit">
    <dtml-var standard_html_footer>

  3. Click the Save Changes button.

This document collects data needed to create an Image. It calls the photoAction document with that data. The photoAction document actually creates the Image. Now let's customize the photoAction document to handle the image title.

  1. Click the photoAction document to edit it.

  2. Change the contents of the document to:

    <dtml-var standard_html_header>
    <h2><dtml-var title></h2>
        id='', file=file, title=photo_title)">
    <p>Thanks for your photo submission.</p>
    <dtml-var standard_html_footer>

The photoAction document uses the <dtml-call> tag to perform an action without inserting anything into the web page. It calls the manage_addImage method on the photoArchive folder. manage_addImage is a folder method that creates a new Image.


You can use forms to pass information between Zope objects. You can programmatically create new Zope objects.

In the next lesson you'll learn about HTTP Cookies and personalizing your web site.

Comments on this lesson? Email feedback.