Home arrow Zope arrow Page 3 - Zope And MySQL

Adapting To The Environment - 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


Normally, setting up a connection between Zope and an external RDBMS like MySQL, Oracle, PostgreSQL or even Gadfly requires two things: a Database Connection object, which is used to perform communication between Zope and the specified database, and one or more Z SQL methods, which are used to execute queries on the database.

Zope comes with adapters for a variety of different databases, including ODBC, Oracle, MySQL and Interbase. I'll be connecting Zope to a MySQL database in this article; however, the process is similar for other database systems.

Hooking Zope up to MySQL is a little tedious, especially if you attempt to do it solely on the basis of the information available online. This is because much of the online documentation relating to Zope-MySQL connectivity is outdated and no longer relevant, and you can lose a whole day just trying out different variants of the techniques suggested. So let me make it as simple as possible.

Getting Zope and MySQL to talk nice to each other requires you to install the following two pieces of software:

1. The Zope MySQL Database Adapter (ZMySQLDA), available from http://www.zope.org/Members/adustman/Products/ZMySQLDA

2. The Python MySQL Database Interface (MySQLdb), a Python MySQL driver available from http://www.zope.org/Members/adustman/Products/MySQLdb

You can also find this software at http://sourceforge.net/projects/mysql-python

The installation process is fairly simple.

1. Install (copy) the ZMySQLDA files into Zope's Products directory (usually <Zope>/lib/python/Products).

2. Extract the MySQLdb files to the same place. Configure and compile the driver (instructions are available in the source archive) using the Python binary that shipped with your version of Zope. This is extremely important, because if you don't use the exact binary that ships with your Zope installation, Zope won't know how to handle the driver.

3. Install the compiled driver into your Zope build (again, instructions to accomplish this are available in the driver's documentation).

4. Restart Zope.

This process works on Linux; however, despite my best efforts, I was unable to get Zope and MySQL talking on Windows. It's certainly possible, though, and the process is about the same - take a look at http://zope.org/Members/philh/ZMySQLDA_html for some hints.

Assuming all goes well, you should now see a new Z MySQL Database Connection object type in the Type drop-down list within the Zope management interface.

If you don't see this item, it usually means that something bad happened during the installation process. Drop by http://www.zope.org/Members/alanpog/zmysqlda_steps and see what you did wrong.

>>> 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: