Opened 18 years ago
Closed 17 years ago
#4218 closed (invalid)
Transactions: Middleware hook at the top
Reported by: | Thomas Güttler | Owned by: | Jacob |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hi,
http://www.djangoproject.com/documentation/transactions/
"""
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.CacheMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
The order is quite important. The transaction middleware applies not only to view functions, but also for all middleware modules that come after it.
"""
I guess most people want that the sessions are part of the transaction. I think
'django.middleware.transaction.TransactionMiddleware' should be at the top of the list.
Actually, since sessions are "lazy" this order doesn't matter; as long as none of the middleware modules before the
TransactionMiddleware}} actually access {{{request.session
-- and none do -- it doesn't matter.