It might seem intimidating, but hooking Zope up to a MySQL database is easier than you think. And once you've got the two talking nice to each other, it becomes even simpler to create dynamic, Zope-based Web applications. Take a look.
So that takes care of adding records. Now, how about deleting them?
You'll remember, from the "list" DTML Method created at the beginning of this exercise, that every item in the DVD list has links pointing to "edit" and "delete" objects, and that these objects are passed the record ID of the corresponding item.
So, in other words, the "delete" object - another DTML Method - needs simply
to use this ID to execute a DELETE query on the table. Let's take a look at the code for this DTML Method:
<a href="list">View the entire collection</a>
or <a href="add">add
No biggie. Like the "add" DTML Method before it, this one too simply functions
as a wrapper for a Z SQL Method, which actually does all the work. In this case, the Z SQL Method is named "deleteMethod" and it receives a record ID as argument. Let's see what that looks like:
DELETE FROM dvd WHERE id = <dtml-sqlvar id type="int">
The "deleteMethod" Z SQL Method contains a simple DELETE query, with the record
ID passed to it inserted dynamically into the query template.