I put a breakpoint inside Session.query(), and I'm seeing some behavior that
I don't understand.

I'm using scoped_session() in my startup code, and calling Session.remove()
in a finally block of my pylons base controller.

This means that each web request should get a completely new SQAlchemy
Session object, if I understand correctly.

If I continue from the breakpoint to the next break, I can inspect the
session after the first query on my page has been run.

I can also confirm, before running the first query, that the session's
identity map is EMPTY.

The model object returned by the first query has a deferred column.

Sometime, if I print this after running the first query:

     self.identity_map.values()[0]._sa_instance_state.callables

I get a hash with containing the loader for the deferred column.

I these cases, if access the deferred column, I can see via some other
logging code that the loader runs at the point.

Other times, if I print the _sa_instance_state.callables (again, starting
with an empty identity_map, and then stepping thru the same first query) I
get back an empty hash.  i.e., no loader.

Accessing the deferred column at this point does not make the loader code
run.  So it's as though the column in question sometimes is not being lazily
loaded.

Can anyone shed light on what's going on?

--bill

-- 
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.

Reply via email to