I've spent a day scratching my head over this now so I figure it's time to seek some outside help. I'm using Elixir and my setup looks like this:
entities.py: class Foo(Entity): # fields ... db_module.py: import elixir from elixir import session as elixir_session def connect_engine(): elixir.metadata.bind = 'connection info' main.py: from entities import Foo from db_module import * def main() connect_engine() # a bunch of stuff foo = Foo() 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. 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. On a somewhat related note, why does Session have so many class methods? It's perplexing to me that I can do things like elixir_session.query(Foo).all() and also elixir_session().query (Foo).all(). I've tried digging through Elixir's entity.py and SQLAlchemy's session.py but I didn't get much out of my first couple of reads. -Eric --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---