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.
connection Database Connection to edit it.A Database Connection tells Zope how to access a relational database.
Browse tab to examine the database tables.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.
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.
Test tab.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.
sightings.html template in the lesson11 folder
to edit it. Notice that the sightings are generated by iterating over the
results of the getSightings ZSQL Method with the tal:repeat
statement.
sightings.html template to:
<html> <div tal:repeat="sighting container/getSightings"> <p><span tal:replace="sighting/date">date</span> -- <span tal:replace="sighting/location">location</span> </p> <p>Reported by <span tal:replace="sighting/name">name</span> </p> <p tal:content="sighting/description">description </p> <hr> </div> </html>
Save Changes button.Test tab to view the page.Zope can work with data from relational databases in the same way it treats other Zope objects.