【发布时间】:2017-09-20 02:38:34
【问题描述】:
我在我的 init 方法中将一个变量设置为一个空列表。然后,在我的 get 方法中,我查询数据库并设置列表。接下来,在我的 post 方法中,我尝试使用该变量。但是,由于某种原因,当我的 post 方法运行时,该变量被设置回一个空列表(这可能是完全可以预期的?)。你能帮我弄清楚我做错了什么,或者让我知道是否有其他方法可以做到这一点?
谢谢!
class thisHandler(BaseHandler):
def __init__(self, *args, **kwargs):
super(thisHandler, self).__init__(*args, **kwargs)
self.topList= []
def get(self, id):
if self.user:
#Other stuff happens
self.topList = get_myList(id) #This is definitely returning a populated list as it displays just fine on my page
#Other stuff happens
self.render('page.html', variables)
def post(self, id):
#Other stuff happens
system.debug(self.topList) #this comes back empty. this is the first reference to it in the post method
#Other stuff happens
【问题讨论】: