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.Click the photoForm
document.
Click the View
tab to view it.
Upload a picture (JPG, GIF, PNG or other graphics format supported by your browser.)
Now return to the lesson8
folder in the Zope management screen
using your browser's back button.
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.
Click the photoForm
document.
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" enctype="multipart/form-data"> <p>Title: <input type="text" name="photo_title"></p> <p>File: <input type="file" name="file"></p> <input type="submit"> </form> <dtml-var standard_html_footer>
Click the Change
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.
Click the photoAction
document to edit it.
Change the contents of the document to::
<dtml-var standard_html_header> <h2><dtml-var title></h2> <dtml-call expr="photoArchive.manage_addImage( 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.
Summary
You can use forms to pass information between Zope objects. You can programmatically create new Zope objects.
Zope documents can be the action of HTML forms.
The <dtml-call> tag performs an action without inserting anything into a web page.
Create new Images in folder with the manage_addImage
method.
In the next lesson you'll learn about HTTP Cookies and personalizing your web site.
Comments on this lesson? Email feedback.