本文整理汇总了Python中map.Map.all方法的典型用法代码示例。如果您正苦于以下问题:Python Map.all方法的具体用法?Python Map.all怎么用?Python Map.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类map.Map
的用法示例。
在下文中一共展示了Map.all方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lookup
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import all [as 别名]
def lookup(type, start, count):
query = Map.all()
if type == "fun":
query.order("-funScore")
elif type == "hard":
query.order("-hardScore")
elif type == "medium":
query.order("-mediumScore")
elif type == "easy":
query.order("-easyScore")
elif type == "recent":
query.filter("good = ", 0)
query.filter("bad = ", 0)
query.filter("ok = ", 0)
query.order("-created")
else:
query.order("name")
# result = []
records = query.fetch(count, start)
# current = 0;
# for record in records:
# result.append(("name" + str(current), str(record.name)))
# result.append(("key" + str(current), str(record.key())))
# current += 1
# result.append(("size", str(current)))
return records
示例2: lookup
# 需要导入模块: from map import Map [as 别名]
# 或者: from map.Map import all [as 别名]
def lookup(type, start, count):
result = []
cursorkey = "cursor-" + type + "-" + str(start)
key = type + "-" + str(start) + "-" + str(count)
cache = memcache.get(key)
if cache is not None:
result = cache
else:
cursor = memcache.get(cursorkey)
query = Map.all()
if type == "fun":
query.order("-funScore")
elif type == "hard":
query.order("-hardScore")
elif type == "medium":
query.order("-mediumScore")
elif type == "easy":
query.order("-easyScore")
elif type == "recent":
query.filter("good = ", 0)
query.filter("bad = ", 0)
query.filter("ok = ", 0)
query.order("-created")
else:
query.order("name")
if cursor is not None:
query.with_cursor(cursor)
records = query.fetch(count)
else:
records = query.fetch(count, start)
current = 0;
for record in records:
result.append(("name" + str(current), str(record.name)))
result.append(("key" + str(current), str(record.key())))
current += 1
result.append(("size", str(current)))
memcache.set(key, result, 3600*24)
cursorkey = "cursor-" + type + "-" + str(start + count)
memcache.set(cursorkey, query.cursor(), 3600)
return result