在python 2.7.2+tornado 3.1.1中,如何使用全局变量?我需要它在AppEngine上工作。你知道吗
class LoginHandler(BaseHandler):
def get(self):
if self.get_current_user():
self.redirect('/')
return
# assign self.get_argument('next', '/')) to the variable next_page
self.render('login.html')
def post(self):
self.set_secure_cookie("user", self.get_argument("username"))
# direct to next_page
存储
next_page
变量不需要全局变量。尝试使用会话或memcache。你知道吗我们使用
'next_page_%s' % user.id
和user.id
作为unigue键,否则每个用户只有一个next_page
。你知道吗您需要将变量指定为每个函数中的全局变量:
有关此问题的更多信息,请参见Using global variables in a function other than the one that created them。你知道吗
相关问题 更多 >
编程相关推荐