Re: [SQLObject] Odd __connection__ problem
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2004-02-05 05:45:18
|
On Feb 4, 2004, at 5:28 PM, Bruno Trevisan wrote: > Hi there > > I'm going through an odd problem while getting connected to a > databse within a class context. > > My code has the usual call: > > __connection__ = PostgresConnection(... > > the call is made in the module context and then every class that > inherits SQLObject within the module has access to the connection > and is able to query the database. This is for the development > environment. I'm not really confident about __connection__ in general, it seems kind of fragile. The basic mechanism is simple enough. When the class is instantiated (that is, when the class: stuff gets run), we look for a _connection attribute. If it's not found, then we look at sys.modules[cls.__module__].__connection__. If for some reason the module can't be found, or __connection__ can't be found, then it will fail. I don't know why this would happen, but I can imagine weird things happening in the module loading that would cause the problem. Otherwise you could track down that code in SQLObjectMeta and put in some print statements to see why __connection__ wasn't found. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |