Re: [sqlalchemy] Re: object_session returns None, but state still has session_id

2011-09-22 Thread Ben Ford
Hi Mike, It is an edge case for sure. I'm using SA with eventlet so the session is going out of scope in a green thread. Eventlet does some monkeying (literally) around with threadlocals so I get a different session for each one. However in this case the parent instance to which I'm adding obj

Re: [sqlalchemy] Re: object_session returns None, but state still has session_id

2011-09-22 Thread Michael Bayer
On Sep 22, 2011, at 5:04 AM, Ben Ford wrote: Hi Mike, It is an edge case for sure. I'm using SA with eventlet so the session is going out of scope in a green thread. Eventlet does some monkeying (literally) around with threadlocals so I get a different session for each one. However in

Re: [sqlalchemy] Re: object_session returns None, but state still has session_id

2011-09-21 Thread Michael Bayer
On Sep 21, 2011, at 11:03 AM, Ben Ford wrote: I've now tried a make_transient so my code looks like this: obj = some object created by adding to a parent's collection ses = object_session(obj) if not ses: make_transient(obj) ses = Session() ses.add(obj) ses.commit() I still