The sqlalchemy cookie cutter uses pyramid_tm to handle the transaction. 
 The docs on that package should answer all your questions:

   https://docs.pylonsproject.org/projects/pyramid_tm/en/latest/

Basically what happens is this:

* the actual transaction management is provided by zope's transaction 
package (http://zodb.readthedocs.io/en/latest/transactions.html)
* the glue between zope and sqlalchemy is zope.sqlalchemy 
(https://pypi.python.org/pypi/zope.sqlalchemy)
* the template uses pyramid_tm to register a transaction around the request 
using a pyramid tween.
* pyramid_tm manages a "meta transaction" that has different components: 
one of which is the database "transaction", but there might also be joined 
transactions for mailing, celery, and other tasks.

When the database transaction fails, an exception is raised.  You can write 
a view to catch that exception, as explained in the pyramid_tm docs.

In your example, two things can happen based on the The order of access in 
the race condition and your DB's configuration.

1. One transaction succeeds, the other fails.
2. Both fail (deadlocks or other db errors).

SqlAlchemy should trap almost any driver error regarding this, and abstract 
it into one of it's own core exceptions 
(http://docs.sqlalchemy.org/en/latest/core/exceptions.html). 

When one of the joined transactions fails, the transaction manager notifies 
the rest to issue a rollback-- so the database should rollback, email 
queues are removed, etc.

-- 
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].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/012c9079-61ed-4462-8d4f-a0a1b8ae4e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to