summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-06-20 23:31:34 -0500
committerDan McGee <dan@archlinux.org>2010-06-20 23:31:34 -0500
commit67f6bc546ec20bd1912aae385220855f9a41a93d (patch)
tree18b1a40c1d18634f0b867bcb637e5ee69942cd87 /main
parentb6efa3443e8f85804650128aea85d3216e0b4933 (diff)
Remove AutoUserMiddleware
This was having some serious effects on caching as we would always have to access the user in the session, marking every page with a "Vary: Cookie" header. This is the start of stamping that out. The way we get the user for news item creation is now more similar to that from the todo lists, but not quite. That should be adjusted to be more like the news item creation. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main')
-rw-r--r--main/middleware.py16
-rw-r--r--main/models.py4
2 files changed, 1 insertions, 19 deletions
diff --git a/main/middleware.py b/main/middleware.py
index 4d343b41..f893c795 100644
--- a/main/middleware.py
+++ b/main/middleware.py
@@ -1,19 +1,3 @@
-import threading
-
-user_holder = threading.local()
-user_holder.user = None
-
-# http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
-class AutoUserMiddleware(object):
- '''Saves the current user so it can be retrieved by the admin'''
- def process_request(self, request):
- user_holder.user = request.user
-
-
-def get_user():
- '''Get the currently logged in request.user'''
- return user_holder.user
-
# begin copy of stock Django UpdateCacheMiddleware
# this is to address feeds caching issue which makes it horribly
# unperformant
diff --git a/main/models.py b/main/models.py
index 7eeec854..793407e9 100644
--- a/main/models.py
+++ b/main/models.py
@@ -3,7 +3,6 @@ from django.db.models import Q
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
-from main.middleware import get_user
from packages.models import PackageRelation
###########################
@@ -121,8 +120,7 @@ class Donor(models.Model):
class News(models.Model):
id = models.AutoField(primary_key=True)
- author = models.ForeignKey(User, related_name='news_author',
- default=get_user)
+ author = models.ForeignKey(User, related_name='news_author')
postdate = models.DateField(auto_now_add=True)
title = models.CharField(max_length=255)
content = models.TextField()