Re: [SQLObject] Caching, and Nonexistant objects
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Ian B. <ia...@co...> - 2003-03-30 02:11:10
|
On Sat, 2003-03-29 at 16:15, Luke Opperman wrote: > Second, very bad things happen if I instantiate an object > with an id that doesn't exist in the database (ie, > Product(43) ). It is instantiated fine, but when an > attribute is accessed it hangs python entirely. The cause of > the hang is unclear at this point, and concerns me, but at a > minimum we need a way to check if an object exists! Our > feeling is that instantiating a non-existant ID should > throw an exception immediately, but alternatively (or as the > implementation of throwing an exception), a function to make > sure the id is valid in the database should be created. > Probably should be in the Connection classes, since all SQL > should ideally be over there.. > > Now that I look through the code again, _SO_autoInit() > should be taking care of this, but that only happens when > attrs are accessed, and that's where the fatal hang is > happening anyways. The fatal hang is bad... it should just be an exception. What do you get from connection.queryOne("SELECT bla FROM wherever WHERE id = 43") ? Or does it hang? The queryOne method should just return None, which'll cause some random exception (should be defined), but I don't know why it would hang. Ian |