Apologies, this went to the wrong list.

Sorry,
Michael


On 8/14/2010 10:28 AM, Michael Hipp wrote:
I'm obviously missing some key concept as regards the management of
sessions. This seemingly simple usage fails:


def get_new():
sess = Session()
new = Something() # new orm object
sess.add(new)
sess.commit()
sess.close()
return new

new = get_new() # request a new Something
print new
print new.id

Those last 2 print lines throw:

DetachedInstanceError: Instance <Something at 0x2873ed0> is not bound to
a Session; attribute refresh operation cannot proceed

I seem to keep butting heads with the session needing to be a global
eternal thing (opposite what the docs recommend). I could create another
session and add 'new' to it, but that seems like a lot of boilerplate
when all I wanted to do was get a bit of info from the returned object.

Can someone explain how this is supposed to be done?

Thanks,
Michael









--
You received this message because you are subscribed to the Google Groups 
"SQLElixir" 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/sqlelixir?hl=en.

Reply via email to