diff gpp/core/middleware.py @ 231:a2d388ed106e

Guard against the request object not having a user attribute in my Who's online middleware. This can happen if a redirect is issued before the authentication middleware gets to run.
author Brian Neal <bgneal@gmail.com>
date Wed, 14 Jul 2010 02:35:39 +0000
parents 08b30ac04580
children e9a066db3f54
line wrap: on
line diff
--- a/gpp/core/middleware.py	Tue Jul 13 03:51:37 2010 +0000
+++ b/gpp/core/middleware.py	Wed Jul 14 02:35:39 2010 +0000
@@ -38,7 +38,12 @@
         """
         Keep track of who is online.
         """
-        if request.is_ajax():
+        # Note that some requests may not have a user attribute
+        # as these may have been redirected in the middleware chain before
+        # the auth middleware got a chance to run. If this is the case, just
+        # bail out. We also ignore AJAX requests.
+
+        if not hasattr(request, 'user') or request.is_ajax():
             return response
 
         if request.user.is_authenticated():