我在我的init方法中將變量設置爲空列表。然後,在我的get方法中,我查詢數據庫並設置列表。接下來,在我的post方法中,我試圖使用該變量。但是,由於某種原因,當我的post方法運行時(這可能是完全可以預料的嗎?),變量會回到空列表中。你能幫我弄清楚我做錯了什麼,或者讓我知道是否有其他方法可以做到這一點?在init中定義變量,在get方法中設置變量,並在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