Gilles Lenfant wrote:
Hi,
Is there a way to do FS based ZSQL methods in a Product ? Actually, my product (under development) uses direct MySQLdb.connections created/deleted for each method. This works but...
1/ It's not easy to be DBMS engine independant that way.
2/ Creating new DB connector for each Web transaction slows down the stuff.
Why dont you use a regular database adaptor from within your Product? Given a eg. MySQL database adapter named 'the_mysql_da', I'd use something like this: import Acquisition from Products.ZSQLMethods.SQL import SQL # this class finds the DA via acquisition class MyZSQLMethods(Acquisition.Implicit): aZSQLMethod = SQL('aZSQLMethod', 'the title', 'the_mysql_DA', 'zsql_param1 zsql_param2', 'select xyz from my_relation ... ') class MyProduct(...): sql = MyZSQLMethods() def someMethod(self): rs = self.sql.aZSQLMethod( zsql_param1='foo', zsql_param2='bar') Take a look into lib/python/Products/ZSQLMethods/SQL.py and lib/python/Shared/DC/ZRDB/DA.py to find out more about the SQL class - peter.