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


Python City.all方法代码示例

本文整理汇总了Python中models.City.all方法的典型用法代码示例。如果您正苦于以下问题:Python City.all方法的具体用法?Python City.all怎么用?Python City.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.City的用法示例。


在下文中一共展示了City.all方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from models import City [as 别名]
# 或者: from models.City import all [as 别名]
    def get(self, action=None):
        if action:
            if action == "turn_download_on":
                turn_download_on()
            if action == "turn_download_off":
                turn_download_off()

        self.response.out.write("Admin page<br/><br/>")
        self.response.out.write('<a href="/gt/">Home</a><br/><br/>')
        self.response.out.write('<a href="/gt/admin/create_geo_trees">Create GeoTrees</a><br/><br/>')
        self.response.out.write('<a href="/_ah/admin">App Engine localhost admin</a><br/><br/>')
        self.response.out.write('<a href="/gt/admin/add_points">Add OSM points to GeoTree</a><br/>')
        self.response.out.write('<a href="/gt/admin/add_cities">Add cities to GeoTree</a><br/><br/>')
        self.response.out.write('<a href="/gt/admin/update_tiles">Update OSM GeoTree tiles</a><br/>')
        self.response.out.write('<a href="/gt/admin/update_cities_tiles">Update Cities GeoTree tiles</a><br/><br/>')
        if is_download_on():
            self.response.out.write('<a href="/gt/admin/turn_download_off">Turn OSM Download OFF</a><br/><br/>')
        else:
            self.response.out.write('<a href="/gt/admin/turn_download_on">Turn OSM Download ON</a><br/><br/>')

        if action:
            if action == "create_geo_trees":
                gt = GeoTree.get(gt_key_name="osm")
                if not gt:
                    gt = GeoTree(key_name="osm", max_z=config.max_z_osm, min_z=config.min_z_osm)
                    gt.put()
                    self.response.out.write("\n\nInfo: Created osm GeoTree.")
                else:
                    gt.max_z = config.max_z_osm
                    gt.min_z = config.min_z_osm
                    gt.put()
                    self.response.out.write("\n\nInfo: OSM GeoTree exists.")
                gt = GeoTree.get(gt_key_name="cities")
                if not gt:
                    gt = GeoTree(key_name="cities", max_z=config.max_z_cities, min_z=config.min_z_cities)
                    gt.put()
                    self.response.out.write("\nInfo: Created cities GeoTree.")
                else:
                    gt.max_z = config.max_z_cities
                    gt.min_z = config.min_z_cities
                    gt.put()
                    self.response.out.write("\nInfo: Cities GeoTree exists.")
            if action == "add_points":
                batch = OSMPOI.all().filter("is_in_tree =", False).fetch(self._BATCH_ADD_SIZE)
                if batch:
                    GeoTree.insert_points_list(batch, max_z=17, gt_key_name="osm")
                    self.response.out.write("\n\nInfo: added %d points" % len(batch))
                    for p in batch:
                        p.is_in_tree = True
                    db.put(batch)
                    taskqueue.add(url="/gt/admin/add_points", method="GET")
                else:
                    if GeoTree.exists(gt_key_name="osm"):
                        self.response.out.write("\n\nInfo: no POIs to add.")
                        taskqueue.add(url="/gt/admin/update_tiles", method="GET")
                    else:
                        self.response.out.write("\n\nInfo: GeoTree does not exist.")
            if action == "add_cities":
                batch = City.all().filter("is_in_tree =", False).fetch(self._BATCH_ADD_SIZE)
                if batch:
                    GeoTree.insert_points_list(batch, gt_key_name="cities")
                    self.response.out.write("\n\nInfo: added %d cities" % len(batch))
                    for p in batch:
                        p.is_in_tree = True
                    db.put(batch)
                else:
                    if GeoTree.exists(gt_key_name="cities"):
                        self.response.out.write("\n\nInfo: no cities left out of tree")
                    else:
                        self.response.out.write("\n\nInfo: GeoTree does not exist")
            if action == "update_tiles":
                message = GeoTree.update_tiles(count=self._BATCH_UPDATE_SIZE, gt_key_name="osm")
                if message:
                    if "nothing to update" in message:
                        self.response.out.write("<br/>" + message)
                else:
                    taskqueue.add(url="/gt/admin/update_tiles", method="GET")
            if action == "update_cities_tiles":
                message = GeoTree.update_tiles(count=self._BATCH_UPDATE_SIZE, gt_key_name="cities")
                if message:
                    self.response.out.write("<br/>" + message)
                else:
                    self.response.out.write("\n\nInfo: updated tiles")
            # memcaching is not used at the moment
            if action == "clear_cache":
                memcache.flush_all()
                self.response.out.write("<br/>All memcache entries are deleted.")
开发者ID:dudarev,项目名称:ololog,代码行数:89,代码来源:geotree_admin.py


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