WSGI does not always have the right request object.

This commit is contained in:
Samuel Clay 2010-06-30 14:09:16 -04:00
parent 80deb056ad
commit 5b7ec31a7a

View file

@ -3,9 +3,11 @@ import datetime
class LastSeenMiddleware(object):
def process_response(self, request, response):
if not request.is_ajax() and request.user.is_authenticated():
if (not request.is_ajax()
and hasattr(request, 'user')
and request.user.is_authenticated()):
request.user.profile.last_seen_on = datetime.datetime.now()
request.user.profile.last_activity_ip = request.META['REMOTE_ADDR']
request.user.profile.last_seen_ip = request.META['REMOTE_ADDR']
request.user.profile.save()
return response