Hi Michael -

Thanks for the response!

> > 1) Isn't this what meta.Session.is_active should be testing for?
>
> it is.   I'm not familiar with a codepath which can cause that to happen,
> and in fact even if the session isn't active, it still should be totally
> fine to call commit().  Try this as an example:
> <snip>

Ok -- I'm glad that this is the case; this does conform with what I'd
seen in other cases in the past.  Indeed -- I also noticed that
is_active seemed to be unnecessary.

> It seems like some unhandled exception on the connection itself might have
> occurred, i.e. after acquiring it via session.connection(), and the
> session wasn't notified of this failure (i.e. via rollback()).

Thank you; that's a helpful direction.  Indeed in this particular
case, I had passed the exception (from session.connection()) into a
class which performed a number of operations.  While that was supposed
to be an atomic unit, perhaps an exception is not being properly
handled in there.

> > I do know, though, that some methods such as remove() are
> > not available on instances -- only on the class.  This is a bit
> > confusing.
>
> remove() is a method on scoped_session() which is not a session.  It is a
> thread local container object with proxying behavior.   If it makes it
> less confusing, you can use scoped_session like this:
>
> # create session registry
> my_scoped_session = scoped_session(sessionmaker())
>
> # acquire the session from the registry
> session = my_scoped_session()
>
> # use the session
> session.commit()
>
> # remove "session" from the current scope
> my_scoped_session.remove()

Yeah, actually, I think that is a clearer convention.  Since we
typically fetch instances and work with them (rather than using
meta.Session.query(), for example), I think I will adopt this naming
convention.

Thanks again!
Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to