【发布时间】:2013-04-20 17:41:07
【问题描述】:
所以我找到了关于在金字塔视图文件中设置会话变量的答案,然后在 mako 模板中访问它。 (How to access session variable in Mako template and Pyramid?)
我想知道你是否可以反过来做。所以而不是:
金字塔视图.py
def thisView(request):
session = request.session
session['selectedclientid'] = 'test' #selectedclient.id
session.save()
webpage.mako
${request.session['selectedclientid']}
我可以换掉它吗?
webpage.mako
${request.session['selectedclientid'] = '5'}
金字塔视图.py
def thisView(request):
someLogicOn(session['selectedclientid'])
到目前为止,我一直未能成功实现它,我不确定这是否只是由于缺乏了解如何做到这一点,还是无法做到这一点。任何建议都会很棒!
【问题讨论】: