From: j.kartnaller <j.k...@ro...> - 2005-12-01 12:12:07
|
I'm creating my objects by implicitly passing the connection to them : conn = ... class A(SQLObject): pass a = A(connection=conn) I do not set processConnection ! There is no problem except when using SingleJoin . SingleJoin uses the select method of otherClass without passing a connection. Select then tries to use the connection contained in the class which is not set in my case. I changed the call to select to pass the connection of the instance : -------------------------------------------------------------------------------- class SOSingleJoin(SOMultipleJoin): ... def performJoin(self, inst): pythonColumn = self.soClass.sqlmeta.style.dbColumnToPythonAttr(self.joinColumn) results = self.otherClass.select(getattr(self.otherClass.q, pythonColumn) == inst.id, connection = inst._connection, ) if results.count() == 0: if not self.makeDefault: return None else: kw = {pythonColumn[:-2]: inst} # skipping the ID (from foreignkeyID) return self.otherClass(**kw) # instanciating the otherClass with all # values to their defaults, except the foreign key # TODO I don't think this is the best way to know the column as foreignKey # reather than foreignKeyID, but I don't found a sqlmeta.style function # to do the work, if there isn't such function, I must create it. else: return results[0] -------------------------------------------------------------------------------- I don't know if this is correct for all cases but it works in my use case. Did I something wrong ? Jürgen |