[sqlalchemy] Re: Caching

2007-12-22 Thread Anton V. Belyaev
merge is working rudimentally for objects with unloaded scalar/ instance/collection attributes in r3974. whats not yet happening is the merging of the various query.options() that may be present on the original deferred loader, which means the merged instance wont necessarily maintain the

[sqlalchemy] Re: Caching

2007-12-21 Thread Anton V. Belyaev
I rearranged instance-level deferred loaders to be serializable instances in r3968. you can now pickle an instance + its _state and restore, and all deferred/lazy loaders will be restored as well. I didnt yet test it specifically with merge() but give it a try, you shoudnt be getting that

[sqlalchemy] Re: Caching

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 3:54 PM, Anton V. Belyaev wrote: 1) I created an object with deferred property (not None). 2) Reloaded it in a new session (to erase deferred property) 3) Pickled/Unpickled 4) Removed everything but properties and _state. what did you remove exactly ? there are some

[sqlalchemy] Re: Caching

2007-12-21 Thread Michael Bayer
On Dec 21, 2007, at 3:54 PM, Anton V. Belyaev wrote: merge worked without an exception this time. merge is working rudimentally for objects with unloaded scalar/ instance/collection attributes in r3974. whats not yet happening is the merging of the various query.options() that may be

[sqlalchemy] Re: Caching

2007-12-20 Thread Anton V. Belyaev
Mike, thanks for your reply. what happens if you just leave _state alone ? there shouldnt be any need to mess with _state (nor _entity_name). the only attribute worth deleting for the cache operation is _sa_session_id so that the instance isnt associated with any particular session when

[sqlalchemy] Re: Caching

2007-12-20 Thread Michael Bayer
pickle isnt going to work with deferred columns unless you implement __getstate__ and __setstate__. so the issue with session.merge() is just an extension of that issue, correct ? i.e. without deferreds merge has no issue. is it not reasonable to ask that objects which are to be

[sqlalchemy] Re: Caching

2007-12-20 Thread Anton V. Belyaev
pickle isnt going to work with deferred columns unless you implement __getstate__ and __setstate__. so the issue with session.merge() is just an extension of that issue, correct ? i.e. without deferreds merge has no issue. is it not reasonable to ask that objects which are to be

[sqlalchemy] Re: Caching

2007-12-20 Thread Michael Bayer
On Dec 20, 2007, at 1:04 PM, Anton V. Belyaev wrote: So, to be cached, an object should fetch all its deferred columns (if any) and provide all of them at __getstate__. Right? that would work. And if an instance from cache has nothing for one of its deferred column values, then

[sqlalchemy] Re: Caching

2007-12-20 Thread Michael Bayer
On Dec 20, 2007, at 1:04 PM, Anton V. Belyaev wrote: And if an instance from cache has nothing for one of its deferred column values, then referencing these properties after merge wont load them from DB, but just fail? I rearranged instance-level deferred loaders to be serializable

[sqlalchemy] Re: Caching

2007-12-19 Thread Michael Bayer
On Dec 19, 2007, at 5:19 PM, Anton V. Belyaev wrote: Hello, Several people already wrote something about memcached + SqlAlchemy. Remember, Mike Nelson wrote a mapper extention, it is available at: http://www.ajaxlive.com/repo/mcmapper.py http://www.ajaxlive.com/repo/mcache.py I've