Mercurial > public > sg101
annotate 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 |
rev | line source |
---|---|
bgneal@626 | 1 """Signal handlers for wiki integration. |
bgneal@626 | 2 |
bgneal@626 | 3 """ |
bgneal@626 | 4 import logging |
bgneal@626 | 5 |
bgneal@626 | 6 from django.contrib.auth.signals import user_logged_in, user_logged_out |
bgneal@626 | 7 |
bgneal@626 | 8 |
bgneal@626 | 9 logger = logging.getLogger(__name__) |
bgneal@626 | 10 |
bgneal@626 | 11 |
bgneal@626 | 12 def login_callback(sender, request, user, **kwargs): |
bgneal@626 | 13 """Signal callback function for a user logging in. |
bgneal@626 | 14 |
bgneal@626 | 15 Sets a flag for the middleware to create an external cookie. |
bgneal@626 | 16 |
bgneal@626 | 17 """ |
bgneal@626 | 18 logger.info('User login: %s', user.username) |
bgneal@626 | 19 |
bgneal@626 | 20 request.session['wiki_set_cookie'] = True |
bgneal@626 | 21 |
bgneal@626 | 22 |
bgneal@626 | 23 def logout_callback(sender, request, user, **kwargs): |
bgneal@626 | 24 """Signal callback function for a user logging in. |
bgneal@626 | 25 |
bgneal@626 | 26 Sets a flag for the middleware to delete the external cookie. |
bgneal@626 | 27 |
bgneal@626 | 28 """ |
bgneal@626 | 29 logger.info('User logout: %s', user.username) |
bgneal@626 | 30 |
bgneal@626 | 31 request.session['wiki_delete_cookie'] = True |
bgneal@626 | 32 |
bgneal@626 | 33 |
bgneal@626 | 34 user_logged_in.connect(login_callback, dispatch_uid='wiki.signals.login') |
bgneal@626 | 35 user_logged_out.connect(logout_callback, dispatch_uid='wiki.signals.logout') |