On Sun, May 31, 2009 at 16:50, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
>
> On May 30, 2009, at 1:56 AM, ericthompso...@gmail.com wrote:
>
>> Upon reaching the instantiation of Foo, my code blows up with the
>> error message in the subject.  Now I realize this is often caused by
>> threading issues - multiple threads, each with their own Session,
>> trying to touch an entity without first merging that entity into the
>> thread's local session.  But my application is single-threaded and to
>> the best of my knowledge I'm not creating any new sessions other than
>> the ScopedSession that was created when I imported elixir.  Even if I
>> had attempted to create several sessions via elixir_session(), my
>> understanding is that I would have been returned the same session
>> because I haven't changed threads and elixir by default uses a
>> ScopedSession.
>
> that is all correct.
>
>> So why is Foo winding up in a new session (and how did
>> it already get attached to my current session)?   I haven't passed any
>> options regarding the session in my entity definitions.
>
> I can't see anything here which would cause this.    A frequent cause
> of this confusion is when a library makes use of the
> ScopedSession.mapper method which has the effect of objects being
> automatically added to a session without the need to say
> session.add(object) - but again confusion would only occur here if
> there is more han one session in use.

FWIW, this is the case with Elixir by default. You can turn that
behavior off if you want though. That explains why your new object
gets attached to the current session as soon as you instanciate your
class. I have no idea why it is using a different session though.


-- 
Gaëtan de Menten
http://openhex.org

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

Reply via email to