【发布时间】:2011-05-03 18:30:41
【问题描述】:
我有一个大约 20 个对象的列表,对于每个对象,我返回一个包含 10 个字典的列表。
我正在尝试为 GAE 列表中的每个对象存储 10 个字典的列表;我认为我没有正确编写代码来将此信息存储到 GAE。
这是我所拥有的:
在我的主要请求处理程序之前,我有这个类:
class Tw(db.Model):
tags = db.ListProperty()
ip = db.StringProperty()
在我的主请求处理程序中,我有以下内容:
for city in lst_of_cities: # this is the list of 20 objects
dict_info = hw12.twitter(city) # this is the function to get the list of 10 dictionaries for each object in the list
datastore = Tw() # this is the class defined for db.model
datastore.tags.append(dict_info) #
datastore.ip = self.request.remote_addr
datastore.put()
data = Data.gql("") #data entities we need to fetch
我不确定这段代码是否是写的。如果有人可以请帮助,将不胜感激。
【问题讨论】:
-
听起来您的列表相当静态。为什么不直接将其存储在代码或数据文件中?
标签: python google-app-engine google-cloud-datastore