If you are using the ZopeTransactionExtension combined with pyramid_tm then the view is irrelevant. pyramid_tm is a tween that wraps everything that happens while processing a request (for the purposes of this discussion).
You should be clear up front that the DBSession is wrapping a database *transaction*. That means that any queries you execute are within that transaction and any updates you flush() are also within that transaction. If there is an error while flushing or another exception in your code that bubbles up, pyramid_tm catches it and aborts the transaction rolling everything back. If there are no exceptions, your view returns, your template renders, etc, then pyramid_tm will commit your transaction, persisting the changes for other requests to see. You may get user.id back from the flush, but that is not actually visible to other requests in your app (using other transactions) until the transaction is actually committed. At the end of the day this is the fundamental concurrency model that you need to understand when using a database. On Wed, Apr 2, 2014 at 12:29 AM, Chung WONG <[email protected]> wrote: > > *def some_view(request):* > * some_code(sqlalchemy_related)* > > * return s <http://user.id/>ome_response* > > if the above execution of view doesn't trigger any error, the transaction > is auto committed with scoped session. > > In case of having an error, the transaction aborted. I guess the "view > handler" can detect: > 1. if there is no error, auto commit the transaction and returns the > response normally. > 2. if there is an error, abort the transaction and throws the proper error. > > Does this mean the "view handler" wait for the outcome of the transaction > and return the response? > > If so, the "view handler" why not wait for the transaction and return the > user.id? > > I think I don't understand how the auto commit mechanism works. > > -- > You received this message because you are subscribed to the Google Groups > "pylons-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/pylons-discuss. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pylons-discuss. For more options, visit https://groups.google.com/d/optout.
