Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-11 Thread Michael Bayer
On Jul 11, 2006, at 2:20 AM, Michael Carter wrote: > Thank you so very much for your help in this. Using SQLAlchemy has > certainly changed the way I think about database access when I'm > designing an application. > that was my entire goal in writing this thing ! --

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
On 7/10/06, Michael Bayer <[EMAIL PROTECTED]> wrote: OK, sorry, one unittest I was too lazy to do was all the various "update"/"expunge"/"detached" combinations with Sessionso i dont think anyone has exhaustively run through these until now.  this was just a one liner in expunge(), try out rev

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Bayer
OK, sorry, one unittest I was too lazy to do was all the various "update"/"expunge"/"detached" combinations with Sessionso i dont think anyone has exhaustively run through these until now.  this was just a one liner in expunge(), try out rev 1698.On Jul 10, 2006, at 6:11 PM, Michael Carter wrot

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
well theres session identifiers that will be stuck on the object ifyou dont expunge it, then when you go to put it into another session it should raise an error. Strangely enough, I don't get those errors. I'll see what the deal is there, but more important is the test transcript I've pasted below.

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Bayer
On Jul 10, 2006, at 5:09 PM, Michael Carter wrote: > u = session.get(User, 1) > session.expunge(u) > cache(u) > session.update(u) > > That code causes u to not exist in the session's identity map. > > u = session.get(User, 1) > cache(u) > > This seems to work fine though. So, is expunge even nece

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
On 7/10/06, Michael Bayer <[EMAIL PROTECTED]> wrote: we're emulating hibernate; thats even though merge() isnt reallycompleted (i.e. doesnt actually "merge" changes in yet).  soheres what hibernate has to say on this:"Use update() if you are sure that the session does not contain an already per

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Bayer
actually, the save_or_update works too.  merge() was supposed to be for restoring serialized instances back to the Session, but I think you can just take the instance right back as well.  the main thing is that the Mapper is compiled; something needs to occur on the mapper in order for this to happ

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Bayer
two changes:line 17 of setup.py: users.mapper.compile()line 15 of test2.py: change:   session.save_or_update(u) to:  u = session.merge(u)On Jul 10, 2006, at 3:49 PM, Michael Carter wrote:Ok, I've got a simple test case here. There are three files: setup.py test1.py test2.py 1. run setup.py to crea

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
Ok, I've got a simple test case here. There are three files: setup.py test1.py test2.py 1. run setup.py to create the sqlite db file 2. run test1.py to create a user and pickle it 3. run test2.py to unpickle the user, check its attributes, and save it to the session ** Make sure test1 and test2 ar

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
er thats a little weird, when you unpickle the object, have all therelevant classes had the same Mappers set up on them ?  the _state attribute is a class-level property accessor that will only be thereif the class has been set up with a mapper (as are all the otherproperties for which youre looki

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Bayer
On Jul 10, 2006, at 2:55 PM, Michael Carter wrote: > That aside and more importantly, I'm still having some issues with > more basic stuff. That is, I can't get a handle on how to use > expunge and update properly. When I pickle an object to a file or > memcache (before or after expunging it

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-10 Thread Michael Carter
caching is a really ambiguous endeavor, if you can lay out yourrequirements more specifically that would help (specifically, whats the lifecycle of a cached object, and what scenarios are you tryingto optimize ?  i.e. do you have expensive SQL, etc.) I'm trying to create a distributed cache for *al

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-07 Thread Michael Bayer
On Jul 5, 2006, at 4:54 PM, Michael Carter wrote: > normally, i would cache whatever relations are loaded on the object > just the way they are. otherwise you have to cache SQL queries > directly since you cant really predict the full SQL/corresponding > result set that is used to load a relatio

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-05 Thread Michael Carter
_attach is not a public function.  you want save_or_update (or  justupdate() if theyre all detached).  follow the code from update()- >_update_impl()->_register_(dirty|clean)()->_attach() to see allextra things you get from that. Thanks. I thought save_or_update did something else, but it is what

Re: [Sqlalchemy-users] External Caching -- Thoughts

2006-07-05 Thread Michael Bayer
On Jul 5, 2006, at 12:34 PM, Michael Carter wrote: > Greetings, > > I am working on a way for my app to cache my sqlalchemy objects > externally, specifically in memcached. I'm in the thinking and > proof of concept stage and I thought I'd ask the list for some wisdom. > > Right now I move ob