From: Luke O. <lu...@me...> - 2003-06-10 05:52:19
|
I have an ugly system in place that i think catches all the cases of stale objects I've used SQLObject for so far, with one caveat. In pseduo-code: perform SQL for id in modifiedIDs: val = connection.cache.get(class, id) connection.cache.purge(class, id) if val is not None: # cached value exists! # rather than decipher all the SQL that was modified newVal = class(id) val.__dict__ = newVal.__dict__ The downside to this is that the versions that existed before this operation are now separated from the cache, and therefore don't act as singleton cached objects anymore. The fix would be to have a .reloadFromDB() or similar (.reload() might be sufficient?) that could reload an object in-place (which just calls _SO_selectOne()/selectInit?), and then this is easy code. (The only challenge now is knowing which IDs to reload, or to query the entire store and reload all... just don't invalidate the cached objects! :) - Luke Quoting Edmund Lian <el...@in...>: > Ian Bicking wrote: > > > Yes, the connections have a query(sql) method, with no return value. > > There's also an attribute conn, which is the actual connection object. > > So long as you aren't using cacheValues, or you aren't modifying rows > > that could have instantiated SQLObject instances, it shouldn't be a > > problem. > > This would be tricky... I thought that just invalidating the cache would > do the trick, but what if the cache contains uncommitted changes? > Hmmm... in the case of absolutely new objects, this won't be an issue > but I think monkeying with data that might already be in the cache is > problematic. > > ...Edmund. > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Etnus, makers of TotalView, The best > thread debugger on the planet. Designed with thread debugging features > you've never dreamed of, try TotalView 6 free at www.etnus.com. > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > -- i find your contempt for naked feet curious. |