コード例 #1
0
ファイル: handlers.py プロジェクト: bellhops/django-tracking2
def track_ended_session(sender, request, user, **kwargs):
    try:
        visitor = Visitor.objects.get(pk=request.session.session_key)
    # This should rarely ever occur.. e.g. direct request to logout
    except Visitor.DoesNotExist:
        return

    # Explicitly end this session. This improves the accuracy of the stats.
    visitor.end_time = timezone.now()
    visitor.time_on_site = (visitor.end_time - visitor.start_time).seconds
    visitor.save()

    # Unset the cache since the user logged out, this particular visitor will
    # unlikely be accessed individually.
    cache.delete(instance_cache_key(visitor))
コード例 #2
0
def track_ended_session(sender, request, user, **kwargs):
    try:
        visitor = Visitor.objects.get(pk=request.session.session_key)
    # This should rarely ever occur.. e.g. direct request to logout
    except Visitor.DoesNotExist:
        return

    # Explicitly end this session. This improves the accuracy of the stats.
    visitor.end_time = timezone.now()
    visitor.time_on_site = (visitor.end_time - visitor.start_time).seconds
    visitor.save()

    # Unset the cache since the user logged out, this particular visitor will
    # unlikely be accessed individually.
    cache.delete(instance_cache_key(visitor))
コード例 #3
0
def post_save_cache(sender, instance, **kwargs):
    cache.set(instance_cache_key(instance), instance, SESSION_COOKIE_AGE)
コード例 #4
0
ファイル: handlers.py プロジェクト: bellhops/django-tracking2
def post_save_cache(sender, instance, **kwargs):
    cache.set(instance_cache_key(instance), instance, SESSION_COOKIE_AGE)