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.
Testtab to view it.
lesson8folder in the Zope management screen using your browser's back button.
photoArchivefolder 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.
<html> <h1 tal:content="template/title">title</h1> <p>Upload a picture to the Elvis Photo Archive.</p> <form action="action.py" method="post" enctype="multipart/form-data"> <p>File: <input type="file" name="file"></p> <p>Title: <input type="text" name="title"></p> <input type="submit"> </form> </html>
This page collects data needed to create an Image. It calls the
action.py script with that data. The
action.py script actually
creates the Image. Now let's customize the script to handle the
action.pyscript to edit it.
""" Create a new image in the photo archive folder. Then return a confirmation page. """ folder=container['photoArchive'] folder.manage_addImage(id='', file=file, title=title) page=container['thanks.html'] return page()
The script collects the form data, creates an image object in a
folder and then returns a thanks page. It gets access to form data
through its parameters. It calls the
manage_addImage folder method
on the photo archive folder to create a new image there. Finally it
locates the thanks page and renders and returns it.
In the next lesson you'll learn about HTTP Cookies and personalizing your web site.