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.In the last lesson you created an Elvis sightings database. Now let's adapt the this database to allow site visitors to submit their own sightings.
This lesson builds on your experience from the last two lessons. To allow folks to report sightings you'll need a report form just like you used in lesson 10.
reportFormDTML Document to view its contents.
This document is almost exactly like the report form used in Lesson
10. It collects data and calls the
reportAction document to
process the data.
reportActionDTML Document to view its contents.
This document is more simple than the
reportAction document in
Lesson 10. All it does is
thank the user and call the
insertSighting ZSQL Method with this
The real work is done by the
insertSighting ZSQL Method. Let's see
insertSightingZSQL Method to view its contents.
The query template contains the following SQL code:
insert into elvis_sightings values( <dtml-sqlvar location type="string">, <dtml-sqlvar date type="string">, <dtml-sqlvar name type="string">, <dtml-sqlvar description type="string"> )
This code inserts a row into the
elvis_sightings table. Notice how
the arguments of this ZSQL Method correspond to the form elements in
You can test this SQL code to make sure it works correctly.
Zope will send the SQL code to the database and will tell you the
SQL code that was sent, and the results that the database
returned. In this case the database will not return anything, since
INSERT command produces no results.
Now return to the
sightings document to see if the sample data was
added to the list of sightings. Play with the system a little bit
and see how the links between the
reportAction documents allow a visitor to navigate the site.
You can easily change data in a relational database with Zope. The process for inserting data is very similar to the process for querying a database; you use a ZSQL Method in both cases.
Comments on this lesson? Email feedback.