[Zope-dev] ZSQLMethod/Z Database Connection namespace

Jeff Coleman jeff@hi-privacy.net
Tue, 29 Oct 2002 10:20:33 -0600


Hi,
I have a product that stores customer information in mysql using
ZSQLMethods.=20
I would like each customer to have a different mysql database (same
structure), but all use the same ZSQLMethods for access.
So, I tried the following:
/ - root contains ZSQLMethods and default DB Connector (seems to be
required for editing the methods)
/CustomerA - contains DB Connector with same name as in root, but uses
different mysql database
/CustomerB - contains DB Connector with same name as in root, but uses
different mysql database

And assumed that /CustomerA/showdata would use the DB Connector in the
'CustomerA' directory, but no matter what it uses the DB Connector in
the root directory.  It seems that the ZSQLMethods namespace is put on
top and any other DB Connectors are ignored.
Is this intentional or a bug?

I can patch Shared.DC.ZRDB.DA with the following:

try: nsCid =3D getattr(aq_parent(self), self.connection_id)
except: ns =3D self
else: ns =3D aq_parent(self)
    	=09
#try: dbc=3Dgetattr(self, self.connection_id) <---<<< old code
try: dbc=3Dgetattr(ns, self.connection_id)

Is this the only way to solve the problem?=20
I hate to add a patch to get what would seem to me to be the correct
functionality.

Thanks,
Jeff