From: Sidnei da S. <si...@re...> - 2003-07-04 19:16:18
|
On Fri, Jul 04, 2003 at 01:49:21PM -0500, Ian Bicking wrote: | On Fri, 2003-07-04 at 11:17, Sidnei da Silva wrote: | Cool... I was wondering how well it would work with Zope 3, and I'm glad | it's not too hard. It's just too bad that Zope 2 is out of the question | :( Indeed :( | > However, Im doing something not that clean which is 'registering' a | > connection with DBConnection._connections by assigning directly to the | > module variable. I would like to see a method to do that (eg: | > DBConnection.registerConnection(name)), so that if it changes in the | > future, any code depending on it doesnt break :) | | I'm not clear what you mean. Can you give an example? Im using the 'feature' of having the SQLObject class attribute '_connection' being a string and having it look the connection on the _connections registry on class creation. from SQLObject.DBConnection import _connections def registerConnection(self, connectionName): cs = zapi.getService(self, SQLDatabaseConnections) conn = cs.getConnection(connectionName) _connections[connectionName] = getAdapter(conn, ISQLConnection) Another approach I tried is: def getFactory(self): klass = getService(self, 'ClassService').getClass(self.className) if not klass._connection: cs = getService(self, SQLDatabaseConnections) conn = cs.getConnection(self.connectionName) klass._connection = getAdapter(conn, ISQLConnection) klass.createTable(ifNotExists=True) return klass But I feel dirty in both cases, for modifying a private variable. []'s -- Sidnei da Silva (dreamcatcher) <si...@x3...> X3ng Web Technology <http://www.x3ng.com.br> GNU/Linux user 257852 Debian GNU/Linux 3.0 (Sid) 2.4.20-powerpc ppc Real Users find the one combination of bizarre input values that shuts down the system for days. ----------------------------------------------------------------------- Verified for virus by mail.redesul.com.br Scanner: clamscan / ClamAV - Version 0.54 - Updated 01/07/2003 |