Skip to content

Commit

Permalink
pylinted files
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfadeev committed Sep 21, 2011
1 parent d2dcfcf commit 47cdfb6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
2 changes: 0 additions & 2 deletions askbot/conf/site_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from askbot.conf.settings_wrapper import settings
from askbot.deps import livesettings
from django.utils.translation import ugettext as _
from django.utils.html import escape
from askbot import const

QA_SITE_SETTINGS = livesettings.ConfigurationGroup(
'QA_SITE_SETTINGS',
Expand Down
7 changes: 0 additions & 7 deletions askbot/const/message_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@
#because you don't want to import _ from here with import *
__all__ = []

This comment has been minimized.

Copy link
@stultus

stultus Sep 21, 2011

So we have to change the django.po file also right?








#messages loaded in the templates via direct _ calls
_('most relevant questions')
_('click to see most relevant questions')
Expand Down
19 changes: 16 additions & 3 deletions askbot/middleware/anon_user.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
from django.utils.translation import ugettext as _
"""middleware that allows anonymous users
receive messages using the now deprecated `message_set()`
interface of the user objects.
To allow anonymous users accept messages, a special
message manager is defined here, and :meth:`__deepcopy__()` method
added to the :class:`AnonymousUser` so that user could be pickled.
Secondly, it sends greeting message to anonymous users.
"""
from askbot.user_messages import create_message, get_and_delete_messages
from askbot.conf import settings as askbot_settings
from askbot import const

class AnonymousMessageManager(object):
"""message manager for the anonymous user"""
def __init__(self, request):
self.request = request

def create(self, message=''):
"""send message to anonymous user"""
create_message(self.request, message)

def get_and_delete(self):
messages = get_and_delete_messages(self.request)
return messages
Expand All @@ -19,6 +31,7 @@ def dummy_deepcopy(*arg):
return None

class ConnectToSessionMessagesMiddleware(object):
"""middleware that attaches messages to anonymous users"""
def process_request(self, request):
if not request.user.is_authenticated():
#plug on deepcopy which may be called by django db "driver"
Expand All @@ -31,5 +44,5 @@ def process_request(self, request):
#also set the first greeting one time per session only
if 'greeting_set' not in request.session:
request.session['greeting_set'] = True
msg = _(askbot_settings.GREETING_FOR_ANONYMOUS_USER)
msg = askbot_settings.GREETING_FOR_ANONYMOUS_USER
request.user.message_set.create(message=msg)

0 comments on commit 47cdfb6

Please sign in to comment.