2011/10/22 Michael Bayer <[email protected]>:

> A single object can only be linked to one Session at a time.  You can 
> transfer state to another while leaving the original unaffected using 
> Session.merge().  If the objects themselves are persistent (i.e. have an id) 
> and are clean (i.e have been flushed, no pending changes) you can use myobj = 
> merge(obj, load=False) which will skip the SQL lookup, if performance is what 
> you're going for here.

I will give the merging a try, but since some objects do not have an
autoincremented id the sessions are not guaranteed to yield equal
results by merging, so I'll probably stick to assertions and warnings.
It's not like I want to encourage that use case. I was merely curious
if it could be accomplished.

> Have you considered working primarily with the non-serialiazed session, then 
> using merge() into the serialized one just for persistence ?  that might be 
> easier.  merge() works well but if you're using it very heavily you might 
> find some quirks.

The thing is, the serialized isolation mode is primarily used to avoid
sprinkling the code with with_lock statements. I have to be sure that
my reads are not just an old snapshot when I execute my writes
depending on current data.

I figure I can always get rid of my serialized session by using manual
locks. But right now performance is not the most important thing to
me, integrity and ease of use is.

Thank you very much for your answer!

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to