Currently getting the following error when moving between askbot pages and our own django app:
'WSGIRequest' object has no attribute 'session'
with traceback ending at
/usr/local/lib/python2.6/dist-packages/Django-1.3.1-py2.6.egg/django/contrib/auth/__init__.py in get_user
107. user_id = request.session[SESSION_KEY]
Suspect this is because askbot is using different session middleware to our own - any ideas?
Minimal repro is: go to askbot section of our site (not logged in), click on "log in" link.
here is our MIDDLEWARE_CLASSES from settings.py:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'askbot.middleware.pagesize.QuestionsPageSizeMiddleware',
'askbot.middleware.cancel.CancelActionMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'askbot.middleware.view_log.ViewLogMiddleware',
'askbot.middleware.spaceless.SpacelessMiddleware')
as far as I can tell, this is merged correctly with the askbot settings.py...
(is it rude to answer my own question, when Evgeny actually answered it? still hopefully this will help for clarity):
settings.pyso, MIDDLEWARE_CLASSES should have been:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
'askbot.middleware.pagesize.QuestionsPageSizeMiddleware',
'askbot.middleware.cancel.CancelActionMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'askbot.middleware.view_log.ViewLogMiddleware',
'askbot.middleware.spaceless.SpacelessMiddleware')
Hi, there is no special session middleware. I am guessing the key is to merge the settings.py correctly for your app and askbot. It is possible that in your case some middlewares are missing or run in incorrect order.
Probably for the debugging purposes you might want to symlink django into current directory and walk with the debugger through the middleware loading stage.
We will improve the auto-tests which run on starting up askbot - that will help with making sure that all necessary pieces are added to the setup.py.
Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.
create your Q&A siteAsked: 2011-11-23 11:27:08 -0500
Seen: 547 times
Last updated: Nov 23 '11
redirect back to askbot after login via own django app
Why do I ImportError: cannot import name signals?
Overlapping heading messages in russian translation
Are there Debian/Ubuntu packages for Askbot?
Bug: SocketServer.py timed out errors on console
My Askbot initialisation snafus
Copyright Askbot, 2010-2011. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.
aha! the exact ordering of the MIDDLEWARE_CLASSES matters!
hjwp ( 2011-11-23 11:44:06 -0500 )editIt does, we'll need to add checks on the middleware order to the startup tests. Did you change order of the first two? Is the problem fixed?
Evgeny ( 2011-11-23 11:49:51 -0500 )edit