diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-01-18 19:26:08 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-01-18 19:26:08 -0300 |
commit | daf0f1ccd75fa81c5e7065bc39df6a6ff792b02f (patch) | |
tree | 511744b3537e89be005ced89f0fbd4988ffab79b /askbot/middleware | |
parent | 72bd812b24005759a8d750a08105799eb2b0a7a8 (diff) | |
download | askbot-daf0f1ccd75fa81c5e7065bc39df6a6ff792b02f.tar.gz askbot-daf0f1ccd75fa81c5e7065bc39df6a6ff792b02f.tar.bz2 askbot-daf0f1ccd75fa81c5e7065bc39df6a6ff792b02f.zip |
removed potentially costly calls from non-askbot urls - works only when askbot is not deployed at root of the site
Diffstat (limited to 'askbot/middleware')
-rw-r--r-- | askbot/middleware/anon_user.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/askbot/middleware/anon_user.py b/askbot/middleware/anon_user.py index 7cd9279d..956990e4 100644 --- a/askbot/middleware/anon_user.py +++ b/askbot/middleware/anon_user.py @@ -8,6 +8,7 @@ added to the :class:`AnonymousUser` so that user could be pickled. Secondly, it sends greeting message to anonymous users. """ +from django.conf import settings as django_settings from askbot.user_messages import create_message, get_and_delete_messages from askbot.conf import settings as askbot_settings @@ -42,6 +43,10 @@ class ConnectToSessionMessagesMiddleware(object): """Enables anonymous users to receive messages the same way as authenticated users, and sets the anonymous user greeting, if it should be shown""" + if not request.path.startswith('/' + django_settings.ASKBOT_URL): + #todo: a hack, for real we need to remove this middleware + #and switch to the new-style session messages + return if request.user.is_anonymous(): #1) Attach the ability to receive messages #plug on deepcopy which may be called by django db "driver" @@ -63,6 +68,10 @@ class ConnectToSessionMessagesMiddleware(object): """Adds the ``'askbot_visitor'``key to cookie if user ever authenticates so that the anonymous user message won't be shown after the user logs out""" + if not request.path.startswith('/' + django_settings.ASKBOT_URL): + #todo: a hack, for real we need to remove this middleware + #and switch to the new-style session messages + return response if hasattr(request, 'user') and \ request.user.is_authenticated() and \ 'askbot_visitor' not in request.COOKIES : |