Skip to main content

Signals for atomic transaction blocks in Django 1.6+

Project description

https://travis-ci.org/nickbruun/django_atomic_signals.png?branch=master

By default, Django does not provide signals for when a database transaction is entered or left. As per various Django tickets, there seems to be no interest in adding this, which has led to a variety of third party solutions. However, due to the changes to transaction handling in Django 1.6, these solutions are no longer functional.

django_atomic_signals provides a Django 1.6 compatible approach to transaction signals through a monkey patching of the django.db.transactions.Atomic context manager.

Installation

To install django_atomic_signals, do yourself a favor and don’t use anything other than pip:

$ pip install django_atomic_signals

Add django_atomic_signals to the list of installed apps in your settings file:

INSTALLED_APPS = (
    'django_atomic_signals',
    ..
)

Usage

django_atomic_signals provides four signals for applications to use:

django_atomic_signals.pre_enter_atomic_block

Emitted prior to attempting to enter an atomic transaction block.

Parameters:
  • using – Database alias being used for the transaction.

  • outermost – Boolean value indicating whether or not the transaction is the outermost transaction, ie. if the transaction will be effectively committed once the transaction is successfully exited.

  • savepoint – Boolean value indicating whether or not the atomic block is a savepoint, ie. if the transaction causes a savepoint to be created.

django_atomic_signals.post_enter_atomic_block

Emitted after an atomic transaction block has been entered.

Parameters:
  • using – Database alias being used for the transaction.

  • outermost – Boolean value indicating whether or not the transaction is the outermost transaction, ie. if the transaction will be effectively committed once the transaction is successfully exited.

  • savepoint – Boolean value indicating whether or not the atomic block is a savepoint, ie. if the transaction causes a savepoint to be created.

django_atomic_signals.pre_exit_atomic_block

Emitted prior to attempting to exit an atomic transaction block.

Parameters:
  • using – Database alias being used for the transaction.

  • outermost – Boolean value indicating whether or not the transaction is the outermost transaction, ie. if the transaction will be effectively committed once the transaction is successfully exited.

  • savepoint – Boolean value indicating whether or not the atomic block is a savepoint, ie. if the transaction causes a savepoint to be created.

  • successful – Boolean value indicating whether or not the database actions within the transaction block were successful.

django_atomic_signals.post_exit_atomic_block

Emitted after an atomic transaction block has been exited.

Parameters:
  • using – Database alias being used for the transaction.

  • outermost – Boolean value indicating whether or not the transaction is the outermost transaction, ie. if the transaction will be effectively committed once the transaction is successfully exited.

  • savepoint – Boolean value indicating whether or not the atomic block is a savepoint, ie. if the transaction causes a savepoint to be created.

  • successful – Boolean value indicating whether or not the database actions within the transaction block as well as the attempt to commit the changes to the database were successful.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-atomic-signals-1.0.0.tar.gz (3.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page