2012-02-12 83 views
4

當我嘗試使用燒杯中分配的東西給會話字典,我得到以下錯誤:如何在瓶子微型框架中使用燒杯會話?

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') 

我跟隨在bottle FAQ教程。

+0

你是否遵循這個'app = SessionMiddleware(app,session_opts)'? – 2012-02-13 04:44:49

回答

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