On Thu, Aug 12, 2010 at 6:44 AM, Guyren G Howe <[email protected]> wrote:

> Confirming this. Going through and adding a session.commit() at the end of
> every function where I execute queries fixes the issue.
> This *appears* to be madness. I can't imagine why one would want a mode of
> access to a database wherein queries are always run in a transaction. But
> I'm certainly willing to be convinced otherwise. :-)


One of two things is happening to you here. Either you are not using the
DBSession provided by TurboGears, or you have something else that happens to
keep requests open indefinitely. I don't know which, but I know that one of
those two must be happening.

Look at this page: http://turbogears.org/2.1/docs/main/RequestFlow.html

As you can see, the Database Session Manager gets started up *very* early in
the stack, with the transaction manager right underneath it. Pretty much
everything that can be wrapped inside of there is. The end result is that,
if your code raises an exception, then the Transaction Manager issues a
rollback, resetting everything to the way it was safely. Otherwise, your
code finishes, the request closes out, and any changes get saved.

The only time I've run into issues myself is when I have tried to access
data that was just committed in a previous request in a new one. If the
prior request didn't get closed yet, then the data was not yet committed,
and the new request was unable to see the data.

So, long story short: Repeat from above. Either you're not using the
transaction manager, or something in your code is preventing the proper
closing of requests. If you're not using the transaction manager, then
commit/begin/etc is, of course, entirely up to your code. If you are using
it, find out what's keeping the request open, and your problem will be
resolved.
-- 
Michael J. Pedersen
My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171
          Yahoo/pedermj2002, MSN/[email protected]

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

Reply via email to