Revision history [back]
Why am I getting a Nonetype error in the code, when the same statment works in a logging directive?
I'm trying to get Askbot working in production on Webfaction. I'm not sure what is going on because the app worked fine for a month, then suddenly, it stopped working. I didn't update the askbot code nor did I change anything on the templates.
The Django debug page is showing:
Exception Value: 'NoneType' object does not support item assignment
Exception Location: /home/username/webapps/askbot/askbot-discussion/askbot/context.py in application_settings, line 31
I decided to log the variables to see why I was getting a NoneType exception immediately before the NoneType error is thrown in the code.
import logging
logging.critical("request[LANGUAGE_CODE] :" + getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) )
my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
This logged: /home/username/webapps/askbot/askbot-discussion/askbot/context.py TIME: 2013-05-03 13:22:53,209 MSG: context.py:application_settings:33 request[LANGUAGE_CODE] :en
As you can see, getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) return "en" for the logging directive.
I'm at a loss for why I'd be getting a NoneType error, because the getattr() worked fine for logging, but for some reason it fails in the actual code.
What is going on?
+++++++EDIT+++++++
Turns out, my Memcache instant had gotten turned off somehow. I restarted Memcache and it started working.
Why am I getting a Nonetype error in the code, when the same statment works in a logging directive?
I'm trying to get Askbot working in production on Webfaction. I'm not sure what is going on because the app worked fine for a month, then suddenly, it stopped working. I didn't update the askbot code nor did I change anything on the templates.
The Django debug page is showing:
Exception Value: 'NoneType' object does not support item assignment
Exception Location: /home/username/webapps/askbot/askbot-discussion/askbot/context.py in application_settings, line 31
I decided to log the variables to see why I was getting a NoneType exception immediately before the NoneType error is thrown in the code.
import logging
logging.critical("request[LANGUAGE_CODE] :" + getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) )
my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
This logged: /home/username/webapps/askbot/askbot-discussion/askbot/context.py TIME: 2013-05-03 13:22:53,209 MSG: context.py:application_settings:33 request[LANGUAGE_CODE] :en
As you can see, getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) return "en" for the logging directive.
I'm at a loss for why I'd be getting a NoneType error, because the getattr() worked fine for logging, but for some reason it fails in the actual code.
What is going on?
+++++++EDIT+++++++
+++++++EDIT+++++++ Turns out, my Memcache instant had gotten turned off somehow. I restarted Memcache and it started working.
Why am I getting a Nonetype error in the code, when the same statment works in a logging directive?
I'm trying to get Askbot working in production on Webfaction. I'm not sure what is going on because the app worked fine for a month, then suddenly, it stopped working. I didn't update the askbot code nor did I change anything on the templates.
The Django debug page is showing:
Exception Value: 'NoneType' object does not support item assignment
Exception Location: /home/username/webapps/askbot/askbot-discussion/askbot/context.py in application_settings, line 31
I decided to log the variables to see why I was getting a NoneType exception immediately before the NoneType error is thrown in the code.
import logging
logging.critical("request[LANGUAGE_CODE] :" + getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) )
my_settings['LANGUAGE_CODE'] = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE)
This logged: /home/username/webapps/askbot/askbot-discussion/askbot/context.py TIME: 2013-05-03 13:22:53,209 MSG: context.py:application_settings:33 request[LANGUAGE_CODE] :en
As you can see, getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) return "en" for the logging directive.
I'm at a loss for why I'd be getting a NoneType error, because the getattr() worked fine for logging, but for some reason it fails in the actual code.
What is going on?
+++++++EDIT+++++++ Turns out, my Memcache instant had gotten turned off somehow. I restarted Memcache and it started working.