Mercurial > public > sg101
comparison 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 |
comparison
equal
deleted
inserted
replaced
230:5ee9422ce83c | 231:a2d388ed106e |
---|---|
36 | 36 |
37 def process_response(self, request, response): | 37 def process_response(self, request, response): |
38 """ | 38 """ |
39 Keep track of who is online. | 39 Keep track of who is online. |
40 """ | 40 """ |
41 if request.is_ajax(): | 41 # Note that some requests may not have a user attribute |
42 # as these may have been redirected in the middleware chain before | |
43 # the auth middleware got a chance to run. If this is the case, just | |
44 # bail out. We also ignore AJAX requests. | |
45 | |
46 if not hasattr(request, 'user') or request.is_ajax(): | |
42 return response | 47 return response |
43 | 48 |
44 if request.user.is_authenticated(): | 49 if request.user.is_authenticated(): |
45 if request.COOKIES.get(ONLINE_COOKIE) is None: | 50 if request.COOKIES.get(ONLINE_COOKIE) is None: |
46 # update the last seen timestamp | 51 # update the last seen timestamp |