Home arrow Zope arrow Page 8 - Zope And MySQL

Erasing The Past - Zope

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.

  1. Zope And MySQL
  2. Making The Connection
  3. Adapting To The Environment
  4. The Magic Of The Movies
  5. Visiting The Box Office
  6. Adding Things Up
  7. Submitting To The King
  8. Erasing The Past
  9. Of Methods And Madness
By: icarus, (c) Melonfire
Rating: starstarstarstarstar / 27
April 10, 2002

print this article


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.

<font size="-1"><a href="edit?id=<dtml-var id>">edit</a> | <a href="delete?id=<dtml-var id>">delete</a></font>
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:

<dtml-var standard_html_header> <dtml-call deleteMethod> <h2>Item deleted!</h2> <p> <a href="list">View the entire collection</a> or <a href="add">add another title</a> <dtml-var standard_html_footer>
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.

Here's what the result page looks like:

>>> More Zope Articles          >>> More By icarus, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Creating Zope Products
- Plone Content Types With Archetypes
- Flat User Management in Zope
- Creating Basic Zope Applications
- Getting started with Zope for Linux and Sola...
- ZPT Basics (part 4)
- ZPT Basics (part 3)
- ZPT Basics (part 2)
- ZPT Basics (part 1)
- Exception Handling In DTML
- DTML Basics (part 4)
- DTML Basics (part 3)
- DTML Basics (part 2)
- DTML Basics (part 1)
- Using Zope With Apache

Developer Shed Affiliates


Dev Shed Tutorial Topics: