[Maas-devel] TransactionMiddleware deprecated

Gavin Panella gavin.panella at canonical.com
Thu Jan 23 23:01:35 UTC 2014


TransactionMiddleware is deprecated in Django 1.6 [1], and a reasonable
replacement seems to be to set ATOMIC_REQUESTS = True globally.

However:

  The transaction middleware applied not only to view functions, but
  also to middleware modules that came after it. For instance, if you
  used the session middleware after the transaction middleware, session
  creation was part of the transaction. ATOMIC_REQUESTS only applies to
  the view itself.

The middleware classes after TransactionMiddleware are:

  django.middleware.csrf.CsrfViewMiddleware
  maasserver.middleware.ExceptionLoggerMiddleware
  django.contrib.auth.middleware.AuthenticationMiddleware
  django.contrib.messages.middleware.MessageMiddleware
  maasserver.middleware.AccessMiddleware
  maasserver.middleware.DebuggingLoggerMiddleware
  django.middleware.gzip.GZipMiddleware

Do any of those need to be within the view's [2] transaction too? If so,
we'll have to roll our own middleware eventually (though that'll largely
be a case of copying TransactionMiddleware).


[1] https://docs.djangoproject.com/en/1.6/topics/db/transactions/

[2] ATOMIC_REQUESTS is badly named, because it's not promising atomicity
    across the whole request, just the view.




More information about the Maas-devel mailing list