[Zope] Database Adapter Madness

Dieter Maurer dieter@handshake.de
Thu, 23 Jan 2003 23:54:31 +0100


Daniel Jackson wrote at 2003-1-21 13:15 -0600:
 > I'm writing a ZClass for a generic SQL table editor. It detects the
 > format of the table, and generates a sortable table with add/edit/delete
 > functions. The ZClass itself is tied to a Database Adaptor that has to
 > be hardcoded to connect to a certian database. This is bad, I need each
 > instance to point to a different database. I cannot find any way to
 > change what database the DA connects to in python or by any other
 > method. If you change the connection string, it affects all of the
 > instances of the zClass. I'm at a loss for ideas on how to do this
 > properly. Right now I have a Psycopg DA inside of the ZClass. Anyone
 > have any hints?
Put a (dummy) DA inside your product (containing your ZClass).
This way, you can add Z SQL methods to your ZClass.

In the ZInstance constructor, add a DA (with the same id as
the dummy) in the created instance (or *much* better)
ensure, each instance can acquire a DA with this id.


Dieter