def index():
"""Lists the coffeez"""
coffees = memcache.get(ALL_COFFEES_KEY)
if not coffees:
coffees = Coffee.query(Coffee.active == True).fetch()
# cannot store all images into memcached due to size limits
for coffee in coffees:
coffee.image = None
memcache.set(ALL_COFFEES_KEY, coffees)
roaster_query = memcache.get(ALL_ROASTERS_KEY)
if not roaster_query:
roaster_query = Coffee.query(projection=["roaster"], distinct=True).fetch()
memcache.set(ALL_ROASTERS_KEY, roaster_query)
roasters = [data.roaster for data in roaster_query]
return render_template('index.html', coffees=coffees, roasters=roasters)
评论列表
文章目录