I have a middleware solution that's supposed to figure out the last
time the visitor was seen (should be familiar to folks that have looked
at the zyons code):
class LastSeen (object):
"""Middleware that adds various objects to thread local storage
from the request object."""
def process_request(self, request):
now = datetime.datetime.now()
try:
l = request.session['last_seen']
last = now -l
# don't update it too often, every 4 hours should be ok
if last.seconds > (60 * 60 * 4):
request.session['last_seen'] =
datetime.datetime.now()
request.session['site_id']= settings.SITE_ID
except KeyError:
request.session['last_seen'] = datetime.datetime.now()
request.session['site_id']= settings.SITE_ID
except TypeError:
request.session['last_seen'] = datetime.datetime.now()
request.session['site_id']= settings.SITE_ID
except SuspiciousOperation:
pass
The problem is that it resets when the visitor first comes to the page.
In other words, when I go to the site first thing in the morning
last_seen resets to NOW. From that point on it works, but then if I go
away for an extended period and come back again, it does the same
thing. I need to keep track of the LAST time they were seen.
Last_Login won't work for me, as I don't force logins, and the field
rarely gets updated.
So, can someone help me get this (or another solution) working?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---