Oliver Bleutgen wrote:
Peter Bengtsson wrote:
You're right. So, if I don't wrap them like that but do define them as attributes, they don't have to reparse them? Then I can do this:
class Mysqlstuff(Aq...):
_login = SQL('null','dummy title', dbconnection, 'name:string pass:string', sqlfile.read()) def login(self, name, pass): ...do other things such as debug... return _login(name=name, pass=pass)
What do you think about that?
I'd guess that this has trouble finding the db connection.
No it finds the dbconnection all right, as long as the class is Acquisition capable Look into Shared.DC.ZRDB.DA.DA.__call__, around line 392
I have had your problem, too, and after a lot of looking around, I found this (maybe it's the right thing for you). http://www.zope.org/Members/jccooper/extzsql
Since I didn't have a lot of SQL-connections, I didn't do it that way. My product looks like this:
from Products.ZSQLMethods.SQL import SQLConnectionIDs
class my_product(...)
def __init__(self,container): wrapped_self = self.__of__(container) wrapped_self._addSQLMethods()
def _addSQLMethods(self): self.manage_addFolder('SQLFolder') SQLFolder = getattr(self,'SQLFolder') addSQL = SQLFolder.manage_addProduct['ZSQLMethods'].manage_addZSQLMethod SQLConnectionID = SQLConnectionIDs(SQLFolder)[0][0] insertSQL = """INSERT INTO bla VALUES (<dtml-sqlvar ... ) """ inserSQLArguments = """name:string ...""" addSQL('insertSQL',...) ...
def refresh(self): """ refresh all instance SQL_methods""" self.manage_delObjects('SQLFolder') self._addSQLMethods()
This is surely not the most elegant way to do it, but it works. And it helps in development to be able to edit/test the sql methods directly.
cheers, oliver
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )