Web.py中的会话导致NameError

时间:2018-10-03 11:35:38

标签: python python-3.x session cookies web.py

使用python 3在web.py中使用登录功能会话会产生500 Internal Server Error。

代码:

app = web.application(urls, globals())
# Session
session = web.session.Session(app, web.session.DiskStore("sessions"), initializer={'user': 'none'})
session_data = session._initializer

render = web.template.render("Views/Templates", base="MainLayout", globals={'session': session_data, 'current_user': session_data['user']})

错误:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/web.py-0.40.dev1-py3.5.egg/web/application.py", line 255, in processreturn p(lambda: process(processors))

  File "/usr/local/lib/python3.5/dist-packages/web.py-0.40.dev1-py3.5.egg/web/session.py", line 83, in _processor self._load()

  File "/usr/local/lib/python3.5/dist-packages/web.py-0.40.dev1-py3.5.egg/web/session.py", line 96, in _load self.session_id = web.cookies().get(cookie_name)

  File "/usr/local/lib/python3.5/dist-packages/web.py-0.40.dev1-py3.5.egg/web/webapi.py", line 487, in cookies ctx._parsed_cookies = parse_cookies(http_cookie)

  File "/usr/local/lib/python3.5/dist-packages/web.py-0.40.dev1-py3.5.egg/web/webapi.py", line 447, in parse_cookies

    cookie = Cookie.SimpleCookie()
NameError: name 'Cookie' is not defined

0 个答案:

没有答案