简体   繁体   English

在GAE上与django进行gae会议

[英]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. 以下是我的错误回溯。我在GAE上将gaesessions与django 1.2结合使用。 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_appengine\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. 当我使用pycharm调试代码时,永远不会输入DjangoSessionMiddleware的process_request函数。 I don'tknnow what is the problem. 我不知道这是什么问题。 Please any one can help? 请任何人能帮忙吗?

I have faced this error quite a few times. 我已经多次遇到此错误。 The reason for this error is incorrect code indentation in views.py . 此错误的原因是views.py代码缩进不正确。

From https://github.com/dound/gae-sessions#readme : 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. 如果要使用Django进行gae会话,请将“ gaesessions.DjangoSessionMiddleware”添加到settings.py文件中的MIDDLEWARE_CLASSES列表中。 You can then access the session associated with the current request via the request.session variable. 然后,您可以通过request.session变量访问与当前请求关联的会话。 To configure the Django middleware, modify the following line in gaesessions/__ init__.py: 要配置Django中间件,请在gaesessions / __ init__.py中修改以下行:

self.wrapped_wsgi_middleware = SessionMiddleware(fake_app, cookie_key='you MUST change this')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM