我是 python 新手,正在尝试定义一个函数,然后在 Google App Engine 中使用它 - 但是当我尝试执行该函数时,我不断收到错误“错误:未定义全局名称'cache_email_received_list'”。任何帮助将不胜感激,谢谢。
这是我的功能:
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()