# HG changeset patch # User Brian Neal # Date 1279074939 0 # Node ID a2d388ed106e3963950f301da93a56729144012b # Parent 5ee9422ce83cfcf2107261e0cf611bc1fbaed163 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. diff -r 5ee9422ce83c -r a2d388ed106e gpp/core/middleware.py --- 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():