/usr/lib/python2.7/dist-packages/ws4redis/models.py is in python-django-websocket-redis 0.4.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # -*- coding: utf-8 -*-
from django.contrib.auth.signals import user_logged_in
from django.dispatch import receiver
@receiver(user_logged_in)
def store_groups_in_session(sender, user, request, **kwargs):
"""
When a user logs in, fetch its groups and store them in the users session.
This is required by ws4redis, since fetching groups accesses the database, which is a blocking
operation and thus not allowed from within the websocket loop.
"""
if hasattr(user, 'groups'):
request.session['ws4redis:memberof'] = [g.name for g in user.groups.all()]
|