[Zope] Re: Global variables in ExternalMethod modules

Ben Last (Zope) zope at benlast.com
Wed Feb 2 08:28:41 EST 2005

Tres Seaver wrote:
> OK.  You probably know this already, but ZMySQLDA provides a persistent 
> object which has pretty much exactly the same semantics:  it holds all 
> the configuration data for the connection, and is responsible for 
> holding open the actual connection across requests.
Yes, we've investigated ZMySQLDA, but our general policy is to keep our 
Python code independent rather than rely on Zope objects.  This isn't to 
denigrate Zope, or the quality of its constituent products, but reflects 
the experiences we've had in building and maintaining a system based 
upon it, together with a desire to remove database dependencies from the 
Zope (presentation) layer altogether, and keep them in the 
business-logic (in ExternalMethods and PythonScripts).
We've also wrapped the Connection objects to allow us to do things like 
divert the connection from the primary to secondary db server if the 
first one fails; this, as far as we could see, isn't easily achievable 
if we let Zope products handle the connections.

> Because it is 
> persistent, you end up (on a busy site) with as many open connections as 
> you have worker threads.
That's exactly the situation we have now, which is working very well. 
One can tune the MySQLdb server to drop connections after an amount of 
idle time, and the class in which we wrap the actual MySQLdb.Connection 
performs a ping() when a Connection is reused, waking the connection up 
again.  Thus the number of simultaneous connections tends to follow the 
load on the site.


More information about the Zope mailing list