当前位置: 首页>>代码示例>>Python>>正文


Python Map.all方法代码示例

本文整理汇总了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
开发者ID:Shattered-Colony-Unbound,项目名称:sc-unbound,代码行数:28,代码来源:update.py

示例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
开发者ID:Shattered-Colony-Unbound,项目名称:sc-unbound,代码行数:42,代码来源:find.py


注:本文中的map.Map.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。