Lesson 12. The Elvis Files, 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.

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.

Click on the form.html template to view its contents.

This page is almost exactly like the report form used in Lesson
10. It collects data and calls the action.py script to
process the data.

This code inserts a row into the elvis_sightings table. Notice how
the arguments of this ZSQL Method correspond to the form elements in
the form.html template.

You can test this SQL code to make sure it
works correctly.

Click on the Test tab.

Enter some sample data into the automatically generated form.

Click the Submit Query button.

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
the SQL INSERT command produces no results.

Now return to the sightings.html page 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 sightings.html, form.html,
and action.py objects allow a visitor to navigate the site.

Summary

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.