Re: [sqlalchemy] DetachedInstanceError

2015-02-23 Thread Michael Bayer
On Feb 22, 2015, at 10:09 PM, Ed Rahn edsr...@gmail.com wrote: I am occassionally and randomly getting a DetachedInstanceError when I try to access an object atttribute that is a reference. I will run this several thousand times and only get it twice. What I don't understand is I use

[sqlalchemy] DetachedInstanceError

2015-02-22 Thread Ed Rahn
I am occassionally and randomly getting a DetachedInstanceError when I try to access an object atttribute that is a reference. I will run this several thousand times and only get it twice. What I don't understand is I use the same exact base query, which is where the reference takes place, and

[sqlalchemy] DetachedInstanceError after transaction

2012-02-14 Thread Jonathan Vanasco
I seem to get this after I call a transaction.commit sqlalchemy.orm.exc.DetachedInstanceError DetachedInstanceError: Instance Useraccount at 0x103f9f610 is not bound to a Session; attribute refresh operation cannot proceed In the following code, the first call will print the id [ i

Re: [sqlalchemy] DetachedInstanceError after transaction

2012-02-14 Thread Claudio Freire
On Tue, Feb 14, 2012 at 6:48 PM, Jonathan Vanasco jonat...@findmeon.com wrote: I will admit that i have some janky db sessioning stuff going on behind the scenes as I get used to pyramid and the new sqlalchemy. Then I'd say the janky db sessioning stuff going on behind the scenes is closing

[sqlalchemy] DetachedInstanceError when calling __repr__

2011-04-07 Thread BenH
Hi, I have an objects that when I convert to a string using __repr__ throws a DetachedInstanceError. If I access any of their members or test the session (using 'user in Session') everything is fine but if I check 'self in Session' in __repr__ the result is False. I can reattach it to the Session

Re: [sqlalchemy] DetachedInstanceError when calling __repr__

2011-04-07 Thread Michael Bayer
On Apr 7, 2011, at 9:54 PM, BenH wrote: Hi, I have an objects that when I convert to a string using __repr__ throws a DetachedInstanceError. If I access any of their members or test the session (using 'user in Session') everything is fine but if I check 'self in Session' in __repr__ the

[sqlalchemy] DetachedInstanceError on assignment

2011-02-11 Thread Joril
Hi everyone! I have a client-server application that communicates like this: the client asks for something, the server fetches the data using SQLAlchemy, serializes it and sends it back to the client. Now the client can modify the data and send it back to the server for persistence. It works

Re: [sqlalchemy] DetachedInstanceError on assignment

2011-02-11 Thread Michael Bayer
On Feb 11, 2011, at 7:43 AM, Joril wrote: Hi everyone! I have a client-server application that communicates like this: the client asks for something, the server fetches the data using SQLAlchemy, serializes it and sends it back to the client. Now the client can modify the data and send it

[sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Hipp
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

Re: [sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Bayer
On Aug 14, 2010, at 12:53 PM, 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()

Re: [sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Hipp
Michael Thanks for taking the time to formulate a very thorough answer. (Now if I can make my understanding be as thorough.) If you could suffer me one more question ... it appears there are two* ways to handle this inside a method that may not know where it's called from. def

Re: [sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Bayer
On Aug 14, 2010, at 3:00 PM, Michael Hipp wrote: Michael Thanks for taking the time to formulate a very thorough answer. (Now if I can make my understanding be as thorough.) If you could suffer me one more question ... it appears there are two* ways to handle this inside a method that

Re: [sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Hipp
On 8/14/2010 2:29 PM, Michael Bayer wrote: The approach above may be fine for your needs but I wouldn't encourage it. The demarcation of transaction boundaries shouldn't be an ad-hoc thing IMO and granular functions shouldn't be deciding whether or not they are setting up a transaction.

Re: [sqlalchemy] DetachedInstanceError

2010-08-14 Thread Michael Bayer
On Aug 14, 2010, at 3:54 PM, Michael Hipp wrote: On 8/14/2010 2:29 PM, Michael Bayer wrote: The approach above may be fine for your needs but I wouldn't encourage it. The demarcation of transaction boundaries shouldn't be an ad-hoc thing IMO and granular functions shouldn't be deciding