comparison wiki/signals.py @ 626:a6bc1e2efa63

Created wiki app to provide integration with MoinMoin. This commit has a working middleware & test.
author Brian Neal <bgneal@gmail.com>
date Wed, 07 Nov 2012 20:17:33 -0600
parents
children a4300639c6e7
comparison
equal deleted inserted replaced
625:08d905e38a86 626:a6bc1e2efa63
1 """Signal handlers for wiki integration.
2
3 """
4 import logging
5
6 from django.contrib.auth.signals import user_logged_in, user_logged_out
7
8
9 logger = logging.getLogger(__name__)
10
11
12 def login_callback(sender, request, user, **kwargs):
13 """Signal callback function for a user logging in.
14
15 Sets a flag for the middleware to create an external cookie.
16
17 """
18 logger.info('User login: %s', user.username)
19
20 request.session['wiki_set_cookie'] = True
21
22
23 def logout_callback(sender, request, user, **kwargs):
24 """Signal callback function for a user logging in.
25
26 Sets a flag for the middleware to delete the external cookie.
27
28 """
29 logger.info('User logout: %s', user.username)
30
31 request.session['wiki_delete_cookie'] = True
32
33
34 user_logged_in.connect(login_callback, dispatch_uid='wiki.signals.login')
35 user_logged_out.connect(logout_callback, dispatch_uid='wiki.signals.logout')