Peter Bengtsson wrote: [snip]
IF I wrap them are class methods, will it correctly look like this:
def Mysqlstuff(Aq...): def zsql_method(self, name, age): return SQL(..., ..., ...)(name=name, age=age)
Or do I need anything else?
This should about work, but it would be more efficient if you stored the ZSQL object somewhere. Otherwise you'd have to reparse the dtml each time you call zsql_method() and won't be able to use zope caching.
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?
Should work -- I use a somewhat different pattern though: class AllSQL(Acquisition.Implicit): zsql = SQL('id', 'title', 'dbconnection', 'arg:type', \ "select foo from bar where <dtml- ...") class ZopeObject(OFS.SimpleItem, ...): sql = AllSQL() def a_method(self): zsql = self.sql.zsql result_set = zsql(arg="spam") ... So I can keep all SQL in one place and I like to separate SQL from Python :-) cheers, peter.