summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2013-01-20 15:09:18 -0600
committerDan McGee <dan@archlinux.org>2013-01-20 15:09:18 -0600
commit45108ea4975419a88c2bb10ed7f3f90d6085d852 (patch)
treeb510397a651d561f4b81f49a1ba97f2520463f8d /main
parent1b1b516bd823d807ea81e62fe14fc92c18d0b89d (diff)
Remove AlwaysCommitMiddleware
Let's just go with the Django database option for PostreSQL autocommit mode instead. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r--main/middleware.py40
1 files changed, 0 insertions, 40 deletions
diff --git a/main/middleware.py b/main/middleware.py
deleted file mode 100644
index a698b13c..00000000
--- a/main/middleware.py
+++ /dev/null
@@ -1,40 +0,0 @@
-from django.core.exceptions import MiddlewareNotUsed
-from django.db import connections
-
-
-class AlwaysCommitMiddleware(object):
- """
- Ensure we always commit any possibly open transaction so we leave the
- database in a clean state. Without this, pgbouncer et al. always gives
- error messages like this for every single request:
-
- LOG S-0x1accfd0: db/user@unix:5432 new connection to server
- LOG C-0x1aaf620: db/user@unix:6432 closing because: client close request (age=0)
- LOG S-0x1accfd0: db/user@unix:5432 closing because: unclean server (age=0)
-
- We only let this middleware apply for PostgreSQL backends; other databases
- don't really require connection pooling and thus the reason for this
- middleware's use is non-existent.
-
- The best location of this in your middleware stack is likely the top, as
- you want to ensure it happens after any and all database activity has
- completed.
- """
- def __init__(self):
- for conn in connections.all():
- if conn.vendor == 'postgresql':
- return
- raise MiddlewareNotUsed()
-
- def process_response(self, request, response):
- """Commits any potentially open transactions at the underlying
- PostgreSQL database connection level."""
- for conn in connections.all():
- if conn.vendor != 'postgresql':
- continue
- db_conn = getattr(conn, 'connection', None)
- if db_conn is not None:
- db_conn.commit()
- return response
-
-# vim: set ts=4 sw=4 et: