Hello. On Thu, Aug 30, 2007 at 10:52:38PM -0500, Kevin J. Rice wrote: > if not selectResults and self.sqlmeta._perConnection and prepName: > statement = "execute %s (%s)" % (prepName, self.id) > selectResults = self._connection.queryOne(statement) > > class Org(SQLObject): > class sqlmeta: > idName = 'OrgID' > table = 'Org' > getByIDPrepName = table + '_getByID' > > def getTransaction(tableList = []): > dsn = "host=127.0.0.1 dbname=dbrel203 user=krice password=chicken4lunch" > > con = PostgresConnection(dsn, debug=0) > for t in tableList: > prepName = None > try: > prepName = t.sqlmeta.getByIDPrepName > except AttributeError: > print "No getByIDPrepName defined." > assert prepName, "Must define a sqlmeta getByIDPrepName for each > table object passed into getTransaction." > dbNames = [col.dbName for col in t.sqlmeta.columnList] > prep = "prepare %s (int) as select %s from %s where (%s.%s) = $1;" % > \ > (t.sqlmeta.table + '_getByID', > ', '.join([x for x in dbNames]), > t.sqlmeta.table, > t.sqlmeta.table, > t.sqlmeta.idName)
Now you need to generalize it: automatically generate getByIDPrepName, PREPARE and EXECUTE statement, so that a user would need only to call an existing API, not to create statements by hand every time (s)he needs it. And of course the new API must not cause troubles for backends that don't support PREPARE/EXECUTE. Oleg. -- Oleg Broytmann http://phd.pp.ru/ [EMAIL PROTECTED] Programmers don't die, they just GOSUB without RETURN. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ sqlobject-discuss mailing list sqlobject-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss