> I think that I'm using sessions wrong. I know I should be creating a
> new session for every request from PB-- but then how do I store a
> persistent copy of the Person object in the Avatar? Should I create a
> new session each time and use session.merge()? I should probably
> *not* use contextual sessions, as, if I understand that correctly, it
> wouldn't only help for a singly-threaded program. I don't need to
> access the database asynchronously, so I think that makes things
> simpler.
>
if you have some kind of long running ORM-mapped instances that need
to participate in multiple sessions on an ad hoc basis, you use
merge() to get them in. It produces a copy of the object local to
that session, which wont be messed with by anything else. You can
only use contextual sessions if you've designed a contextual function
that interacts brilliantly with twisted's concurrency model. In this
case, such as, per-Avatar; assuming the Avatar corresponds to exactly
one single process of work (i.e. no concurrent access). You
definitely do *not* want to use the default thread local behavior
since Twisted implements concurrency without threads necessarily being
involved.