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.
Everyone knows that serious web sites use databases. We agree. Let's convert our Elvis sightings system to use a relational database. This will provide us with scalability and interoperability.Let's see how Zope gets data from a database.
Click the connection
Database Connection to edit it.
A Database Connection tells Zope how to access a relational database.
Click the Browse
tab to examine the database tables.
Click the plus box next to the ELVIS_SIGHTINGS
table to
expand it.
Now you can see the column names and types for this table. Now let's see how to get information out of this table.
Click the getSightings
ZSQL Method in the lesson11
folder
to edit it.
Notice that the SQL statement used to fetch information about Elvis
sightings is editable in the Query template
field.
Click the Test
tab.
Click the Submit Query
button.
This shows you what data the ZSQL Method returns.
A ZSQL Method is used to get information out of or into a relational database.
Now let's see how to use this ZSQL Method in a web page.
Click the sightings
DTML Document in the lesson11
folder
to edit it.
Notice that the sightings are generated by iterating over the
sightings
ZSQL Method with the <dtml-in>
tag.
Add a line between each sighting by changing the contents of
the sightings
DTML Document to::
<dtml-var standard_html_header> <h2><dtml-var title></h2> <dtml-in getSightings> <p><dtml-var date> -- <dtml-var location></p> <p>Reported by <dtml-var name></p> <p><dtml-var description></p> <hr> </dtml-in> <dtml-var standard_html_footer>
Click the Change
button.
Click the View
tab to view the document.
Summary
Zope can work with data from relational databases in the same way it treats other Zope objects.
Database Connections tell Zope about relational databases.
ZSQL Methods get information out of or into a relational database.
Comments on this lesson? Email feedback.