How to use beaker session in bottle micro framework?

混江龙づ霸主 提交于 2019-12-09 03:17:10

问题


When I try to assign something to the session dictionary using beaker, I get the following error:

Traceback (most recent call last):
    rv = callback(*a, **ka)
  File "controllers.py", line 30, in login
    s['email'] = email
TypeError: 'NoneType' object does not support item assignment
1.0.0.127.in-addr.arpa - - [12/Feb/2012 18:48:52] "POST /login HTTP/1.1" 500 746

where

s = bottle.request.environ.get('beaker.session')

I follow the tutorial at the bottle FAQ.


回答1:


session_opts = {
    'session.type': 'file',
    'session.cookie_expires': 300,
    'session.data_dir': './data',
    'session.auto': True
}
myapp = SessionMiddleware(app, session_opts)
run(app=myapp)


来源:https://stackoverflow.com/questions/9248245/how-to-use-beaker-session-in-bottle-micro-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!