From: Jonathan Daugherty <cygnus@cp...> - 2006-01-20 03:49:42
I'm using SQLObject 0.6 and Python 2.3. I'm new to SQLObject, and
it's very enjoyable.
I'm trying to decide how best to set my connection object so all of my
SQLObject classes can have access to it. It appears that I have three
- Use a _connection attribute in the class definition itself
- Use a module global, __connection__, in the module where the
SQLObject classes live
- Call setConnection() on my SQLObject classes to set their
connection object once I've created it
I would like to be able to set the connection object for my classes as
part of my program initialization logic (i.e. not as __connection__ or
I'm thinking I might write a function which, given a connection object
C, will check the contents of the module where my classes live, find
the SQLObject subclasses, and call setConnection(C) on them. Is this
solution wacky? How does one usually go about solving this problem?