如何在瓶子微框架中使用烧杯会话? [英] How to use beaker session in bottle micro framework?

查看:66
本文介绍了如何在瓶子微框架中使用烧杯会话?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用烧杯将某些东西分配给会话字典时,出现以下错误:

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

其中

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

我遵循瓶常见问题解答中的教程.

推荐答案

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

这篇关于如何在瓶子微框架中使用烧杯会话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆