0
讓我們假設我使用默認的金字塔UnencryptedCookieSessionFactory
如何在金字塔會話中存儲值?
...
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
config = Configurator(settings=settings)
config.set_session_factory(my_session_factory)
...
,並定義了兩個意見一個鏈接到對方:
@view_config(route_name='t1')
def t1(request):
session = request.session
session['fred'] = '***'
session['abc'] = '&&&'
return Response(str(session.__dict__) + '<a href="t2">t2</a>')
@view_config(route_name='t2')
def t2(request):
session = request.session
return Response(str(session.__dict__) + '<a href="t1">t1</a>')
如果我遊T1在瀏覽器中我得到以下的輸出:
{'accessed': 1377760577, '_dirty': True, 'request': , 'new': False, 'created': 1377760540.30155}t2
如果我按照鏈接t2:
{'accessed': 1377760577, 'request': , 'new': False, 'created': 1377760540.30155}t1
但我希望的東西t1和t2不同:
{ ..., 'fred': '***', 'abc': '&&&', ...}
爲什麼值不保存在session? _dirty標誌是什麼意思?