4. Concurrency
● Has to be handled by the developer.
● 'Transient errors' are common.
● If at first you don't succeed, try again.
● Transaction manager looks for should_retry method.
zope.sqlalchemy
def should_retry(self, error):
if isinstance(error, ConcurrentModificationError):
return True
if isinstance(error, DBAPIError):
orig = error.orig
for error_type, test in _retryable_errors:
if isinstance(orig, error_type):
if test is None:
return True
if test(orig):
return True
Transaction aware middleware
● WSGI in general: repoze.tm2
● Pyramid: pyramid_tm
Other transaction features
● Multiple data managers
● Before and after commit hooks
● Synchronizers
● Notes
Thank You!
● Transaction documentation:
http://zodb.readthedocs.org/en/latest/transactions.html
● Contact me:
cguardia on twitter
cguardia@yahoo.com
#pyramid IRC channel