gae sessions with django on GAE
Please need some help on this. Following is my error traceback.I'm using gaesessions with django 1.2 on GAE. I'm getting following error:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 4053, in _HandleRequest
self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3977, in _Dispatch
base_env_dict=env_dict)
File "C:\Program Files\Google\google_appen开发者_开发百科gine\google\appengine\tools\dev_appserver.py", line 588, in Dispatch
base_env_dict=base_env_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 3050, in Dispatch
self._module_dict)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2954, in ExecuteCGI
reset_modules = exec_script(handler_path, cgi_path, hook)
File "C:\Program Files\Google\google_appengine\google\appengine\tools\dev_appserver.py", line 2834, in ExecuteOrImportScript
exec module_code in script_module.__dict__
File "D:\projects\tutorial\selftutor.py", line 38, in <module>
main()
File "D:\projects\tutorial\selftutor.py", line 35, in main
util.run_wsgi_app(application)
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py", line 98, in run_wsgi_app
run_bare_wsgi_app(add_wsgi_middleware(application))
File "C:\Program Files\Google\google_appengine\google\appengine\ext\webapp\util.py", line 116, in run_bare_wsgi_app
result = application(env, _start_response)
File "C:\Program Files\Google\google_appengine\lib\django_1_2\django\core\handlers\wsgi.py", line 252, in __call__
response = middleware_method(request, response)
File "D:\projects\tutorial\gaesessions\__init__.py", line 491, in process_response
if request.session.is_accessed():
AttributeError: 'WSGIRequest' object has no attribute 'session'
On one link it is working. There is no error but on another above error is shown. When I debug the code using pycharm 'process_request' function of the 'DjangoSessionMiddleware' is never entered. I don'tknnow what is the problem. Please any one can help?
From https://github.com/dound/gae-sessions#readme :
If you want to gae-sessions with Django, add 'gaesessions.DjangoSessionMiddleware' to your list of MIDDLEWARE_CLASSES in your settings.py file. You can then access the session associated with the current request via the request.session variable. To configure the Django middleware, modify the following line in gaesessions/__ init__.py:
self.wrapped_wsgi_middleware = SessionMiddleware(fake_app, cookie_key='you MUST change this')
I have faced this error quite a few times. The reason for this error is incorrect code indentation in views.py
.
精彩评论