From 7e4f1d542e00b4d3121da6ae5524e95867f2371b Mon Sep 17 00:00:00 2001 From: root Date: Fri, 13 Nov 2009 20:18:55 -0500 Subject: better comments, email subscriptions, corrected view counter, some ie7 issues, wiki optional with settings.WIKI_ON, site can be mounted on arbitrary url prefix, english language improvements, added feedback form, versioned css and js files to force browser cache reload when settings.RESOURCE_REVISION is incremented , other fixes --- middleware/anon_user.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 middleware/anon_user.py (limited to 'middleware/anon_user.py') diff --git a/middleware/anon_user.py b/middleware/anon_user.py new file mode 100644 index 00000000..c7ff05bc --- /dev/null +++ b/middleware/anon_user.py @@ -0,0 +1,26 @@ +from django.http import HttpResponseRedirect +from django_authopenid.util import get_next_url +from user_messages import create_message, get_and_delete_messages +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 -- cgit v1.2.3-1-g7c22 From 46e48e400f30bde76a9b21db78f9b727149a3e24 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Tue, 17 Nov 2009 22:14:15 -0500 Subject: full text search with Sphinx, added session-based greeting message for the first time visitor --- middleware/anon_user.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'middleware/anon_user.py') diff --git a/middleware/anon_user.py b/middleware/anon_user.py index c7ff05bc..8422d89b 100644 --- a/middleware/anon_user.py +++ b/middleware/anon_user.py @@ -1,6 +1,8 @@ from django.http import HttpResponseRedirect from django_authopenid.util import get_next_url +from django.utils.translation import ugettext as _ from user_messages import create_message, get_and_delete_messages +import settings import logging class AnonymousMessageManager(object): @@ -24,3 +26,9 @@ class ConnectToSessionMessagesMiddleware(object): 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) -- cgit v1.2.3-1-g7c22