bgneal@626: """Signal handlers for wiki integration. bgneal@626: bgneal@626: """ bgneal@626: import logging bgneal@626: bgneal@626: from django.contrib.auth.signals import user_logged_in, user_logged_out bgneal@626: bgneal@626: bgneal@626: logger = logging.getLogger(__name__) bgneal@626: bgneal@626: bgneal@626: def login_callback(sender, request, user, **kwargs): bgneal@626: """Signal callback function for a user logging in. bgneal@626: bgneal@626: Sets a flag for the middleware to create an external cookie. bgneal@626: bgneal@626: """ bgneal@626: logger.info('User login: %s', user.username) bgneal@626: bgneal@626: request.session['wiki_set_cookie'] = True bgneal@626: bgneal@626: bgneal@626: def logout_callback(sender, request, user, **kwargs): bgneal@626: """Signal callback function for a user logging in. bgneal@626: bgneal@626: Sets a flag for the middleware to delete the external cookie. bgneal@626: bgneal@626: """ bgneal@626: logger.info('User logout: %s', user.username) bgneal@626: bgneal@626: request.session['wiki_delete_cookie'] = True bgneal@626: bgneal@626: bgneal@626: user_logged_in.connect(login_callback, dispatch_uid='wiki.signals.login') bgneal@626: user_logged_out.connect(logout_callback, dispatch_uid='wiki.signals.logout')