技术探索:Google App Engine、Zenoss与Python包管理
1. Google App Engine数据查询代码分析
在Google App Engine开发中,有一段代码用于从数据存储中抓取最后10条记录:
collection = []
#grab last 10 records from datastore
query = ChangeModel.all().order('-date')
records = query.fetch(limit=10)
#formats decimal correctly
for change in records:
collection.append(decimal.Decimal(change.input)/100)
template_values = {
'inputs': collection,
'records': records,
}
path = os.path.join(os.path.dirname(__file__), 'query.html')
self.response.out.write(template.render(path,template_values))
其中关键的两行代码为:
query = ChangeModel.all().order('-date')
records = query.fetch(limit=10)
这两行代码的作用是从数据存储中提取结果,并在查
超级会员免费看
订阅专栏 解锁全文
8

被折叠的 条评论
为什么被折叠?



