summaryrefslogtreecommitdiffstats
path: root/middleware/anon_user.py
diff options
context:
space:
mode:
authorhrcerqueira <hrcerqueira@gmail.com>2010-02-18 00:14:01 +0000
committerhrcerqueira <hrcerqueira@gmail.com>2010-02-18 00:14:01 +0000
commit710574352dabcab4c710f2795a26501e54329e79 (patch)
treec34a60217501a582d6fe5b7f0ca655d88bd03c62 /middleware/anon_user.py
parent473bdf5773aed8bdd91a16e371f75e628d20511e (diff)
downloadaskbot-710574352dabcab4c710f2795a26501e54329e79.tar.gz
askbot-710574352dabcab4c710f2795a26501e54329e79.tar.bz2
askbot-710574352dabcab4c710f2795a26501e54329e79.zip
Fixed some errors and moved some folders to inside the forum folder.
Diffstat (limited to 'middleware/anon_user.py')
-rw-r--r--middleware/anon_user.py34
1 files changed, 0 insertions, 34 deletions
diff --git a/middleware/anon_user.py b/middleware/anon_user.py
deleted file mode 100644
index fa2686f0..00000000
--- a/middleware/anon_user.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from django.http import HttpResponseRedirect
-from utils.forms import get_next_url
-from django.utils.translation import ugettext as _
-from user_messages import create_message, get_and_delete_messages
-from django.conf import settings
-import logging
-
-class AnonymousMessageManager(object):
- def __init__(self,request):
- self.request = request
- def create(self,message=''):
- create_message(self.request,message)
- def get_and_delete(self):
- messages = get_and_delete_messages(self.request)
- return messages
-
-def dummy_deepcopy(*arg):
- """this is necessary to prevent deepcopy() on anonymous user object
- that now contains reference to request, which cannot be deepcopied
- """
- return None
-
-class ConnectToSessionMessagesMiddleware(object):
- def process_request(self, request):
- if not request.user.is_authenticated():
- request.user.__deepcopy__ = dummy_deepcopy #plug on deepcopy which may be called by django db "driver"
- request.user.message_set = AnonymousMessageManager(request) #here request is linked to anon user
- request.user.get_and_delete_messages = request.user.message_set.get_and_delete
-
- #also set the first greeting one time per session only
- if 'greeting_set' not in request.session:
- request.session['greeting_set'] = True
- msg = _('first time greeting with %(url)s') % {'url':settings.GREETING_URL}
- request.user.message_set.create(message=msg)