Re: [SQLObject] BUG: ForeignKey in another database
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-11-19 18:16:28
|
On Nov 19, 2003, at 10:27 AM, J-P Lee wrote: > OK, I've narrowed this down. It works fine when accessing the records > directly using Notes(1).user.name. However, when iterating over a > query result, it fails. > > for rec in Notes.select(): > print rec.user.name > > I'm looking at the differences between the versions. With the latest > release, conn is being passed along whereas in the previous release > it's retrieved from the instance. I assume all this connection > passing was added to resolve transaction problems. Is there a way to > make iterSelect work using 2 databases? Mmm... I guess it was an unintended feature of 0.4 that you could do cross-database joins. I'm guessing you could do: for rec in Notes.select(): user = User(rec.userID) print user.name or: class Notes(SQLObject): .... def _get_user(self): return User(self.userID) Probably the best way to handle this would be to separate transactions from databases and connections. That is, you'd have one transactional context, which would potentially connect to multiple databases, and multiple specific database connections. Then you'd attach classes to a database, and this attachment would be fairly strong (stronger than currently, where now you can suddenly "move" an instance to another database by passing in a connection= parameter). Anyway, that's what should happen to SQLObject in the future, and it might produce cleaner code, because transactions are kind of wonky right now. But for now a workaround will have to do. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |