我是python的新手,試圖定義一個函數,然後在Google App Engine中使用它 - 但我不斷收到錯誤「Error:global name'cache_email_received_list'is not defined」when我嘗試執行該功能。任何幫助將不勝感激,謝謝。在Google App Engine中定義Python函數
這裏是我的功能:
class EmailMessageHandler(BaseHandler2):
def cache_email_sent_list(): #set email_sent_list to memcache
email_sent_list = db.GqlQuery("SELECT * FROM EmailMessage WHERE sender =:1 ORDER BY created DESC", user_info.username)
if email_sent_list:
string1 = "email_sent_list"
email_sent_list_cache_id = "_".join((user_info.username, string1))
memcache.set('%s' % email_sent_list_cache_id, email_sent_list, time=2000000)
logging.info('**************email_sent_list added to memcache*********')
這裏就是我想稱之爲:
if email_received_list is None and email_sent_list is not None:
params = {
'email_sent_list': email_sent_list,
}
cache_email_sent_list()
我沒有看到'cache_email_received_list'定義或在任何地方使用。 –