[Zope] ZSQL method and database connection acquisition.

jon@totient.demon.co.uk jon@totient.demon.co.uk
Sat, 1 Sep 2001 12:49:59 +0100 (BST)


Hi 

context:
Zope 2.3.2 (source release, python 1.5.2, linux2) 
Python 1.5.2 (#1, Feb 1 2000, 16:32:16) [GCC egcs-2.91.66 19990314/Linux (egcs- 
Platform linux-i386 
ZMySQLDA 2.0.0

Making zope acquire the database connection appears to be slightly
cumbersome.

I have a folder X with many ZSQLMethods inside it. To add these
I had to add a connection object to folder X before hand.

However I have other folders say test1 and test2 in which I place
a database connection with the same id but connecting to different
databases. I am have the same schema in two databases, so I want to
group the sql all together and then use the differing connections
in different folders to manipulate the data differently.

so we have (as a minimum)

/X containing
       dbconn ; a 'fake' database connection
       a_sql_method ; uses dbconn
/test1
	dbconn ; a database connection to database1

/test2 
       dbconn ; a database connection to database2


Now once this is all set up you have to delete the /X/dbconn.
(If you rename it though, the connection_id in the sql_method
changes as well, which makes the calls from the test1/2 folders
break). So delete it you must.

and then using the magic of acquistion call

/X/test1/a_sql_method  

and this queries on database1

and
/X/test2/a_sql_method

and this queries database2

However if you want to add any more sql methods into the X folder
or modify an existing one, zope requires that there be an existing
database connection in that folder.

This seems to go against the spirit of acquistion. If the connection
is not visible in that folder the only thing that shouldnt work is the
'test' tab. The SQL method and the database connection seem too
tightly coupled to me.

any ideas? any fixes?

I'll try on 2.4.x the minute I get the mysql-python and python 2.1 built.


Jon