tags:

views:

26

answers:

1

Where I work, we use Pylons for our web development framework. Every so often when debugging an error using Pylons' interactive debugger, I encouter a traceback that includes the following type of error regarding a variable, etc. not being bound to a session:

UnboundExecutionError: Instance is not bound to a Session; attribute refresh operation cannot proceed

When this error is present, I am never able to output what a variable, etc affected by this error type is equal to at the interactive debugger prompt. However, I am able to log this information to the paster shell I have running in my terminal. Has anyone ever encountered something similar, or can tell why this error occurs?

A: 

It's an SQLAlchemy error. To avoid it, eagerly load all of the object attributes before an exception happens, and then you should be able to inspect that object.

AFAIU this error happens because BaseController destroys the session when an exception happens (there's a try:/finally: statement that calls meta.Session.remove()), so when you get to a debugger the session is already gone and objects associated with that session cannot access it any more.

Marius Gedminas