diff wiki/signals.py @ 629:f4c043cf55ac

Wiki integration. Requests don't always have sessions. In particular this occurs when a request is made without a trailing slash. The Common middleware redirects when this happens, and the middleware process_request() processing stops before a session can get added. So just set an attribute on the request object for each operation. This seemed weird to me at first, but there are plenty of examples of this in the Django code base already.
author Brian Neal <bgneal@gmail.com>
date Tue, 13 Nov 2012 13:50:06 -0600
parents a4300639c6e7
children 63603e931503
line wrap: on
line diff
--- a/wiki/signals.py	Mon Nov 12 16:40:54 2012 -0600
+++ b/wiki/signals.py	Tue Nov 13 13:50:06 2012 -0600
@@ -1,11 +1,14 @@
 """Signal handlers for wiki integration.
 
+We are interested in hearing about users logging in and out, so we can create
+and destroy an external cookie to allow access to the wiki.
+
 """
 import logging
 
 from django.contrib.auth.signals import user_logged_in, user_logged_out
 
-from wiki.constants import SESSION_SET_FLAG, SESSION_SET_MEMBER
+from wiki.constants import SESSION_SET_MEMBER
 
 logger = logging.getLogger(__name__)
 
@@ -18,7 +21,7 @@
     """
     logger.info('User login: %s', user.username)
 
-    request.session[SESSION_SET_FLAG] = True
+    request.wiki_set_cookie = True
 
 
 def logout_callback(sender, request, user, **kwargs):