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


Python Protocol.read方法代码示例

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


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

示例1: ZonesController

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
class ZonesController(BaseController):
    readonly = True # if set to True, only GET is supported

    def __init__(self):
        self.protocol = Protocol(Session, Zone, self.readonly)

    @geojsonify
    def index(self, format='json'):
        """GET /: return all features."""
        # If no filter argument is passed to the protocol index method
        # then the default MapFish filter is used.
        #
        # If you need your own filter with application-specific params 
        # taken into acount, create your own filter and pass it to the
        # protocol read method.
        #
        # E.g.
        #
        # from sqlalchemy.sql import and_
        #
        # default_filter = create_default_filter(request, Zone)
        # filter = and_(default_filter, Zone.columname.ilike('%value%'))
        # return self.protocol.read(request, filter=filter)
        if format != 'json':
            abort(404)
        return self.protocol.read(request)

    @geojsonify
    def show(self, id, format='json'):
        """GET /id: Show a specific feature."""
        if format != 'json':
            abort(404)
        return self.protocol.read(request, response, id=id)


    #@geojsonify
    #def create(self):
    #    """POST /: Create a new feature."""
    #    return self.protocol.create(request, response)
    #
    #@geojsonify
    #def update(self, id):
    #    """PUT /id: Update an existing feature."""
    #    return self.protocol.update(request, response, id)
    #
    #def delete(self, id):
    #    """DELETE /id: Delete an existing feature."""
    #    return self.protocol.delete(request, response, id)


    def count(self):
        """GET /count: Count all features."""
        return self.protocol.count(request)
开发者ID:gocodeboulder,项目名称:hotspots-mapfish,代码行数:55,代码来源:zones.py

示例2: test_protocol_read_all

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
    def test_protocol_read_all(self):
        """Return all features"""
        proto = Protocol(session, Spot)

        collection = proto.read(FakeRequest({}))
        ok_(collection is not None)
        ok_(isinstance(collection, FeatureCollection))
        eq_(len(collection.features), 9)
开发者ID:123rohan123,项目名称:mapfish,代码行数:10,代码来源:test_postgis.py

示例3: test_protocol_read_one

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
    def test_protocol_read_one(self):
        """Return one feature"""
        proto = Protocol(session, Spot)

        feature = proto.read(FakeRequest({}), id=1)
        ok_(feature is not None)
        ok_(isinstance(feature, Feature))
        eq_(feature.id, 1)
        eq_(feature.geometry.coordinates, (0.0, 0.0))
        eq_(feature.properties["spot_height"], 420.39999999999998)
开发者ID:123rohan123,项目名称:mapfish,代码行数:12,代码来源:test_oracle.py

示例4: test_protocol_read_one_null

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
    def test_protocol_read_one_null(self):
        """Return one null feature"""
        proto = Protocol(session, Spot)

        feature = proto.read(FakeRequest({}), id=9)
        ok_(feature is not None)
        ok_(isinstance(feature, Feature))
        eq_(feature.id, 9)
        # make use of __geo_interface__ property since 'geometry'
        # value is not the same in various versions of geojson lib
        ok_(feature.__geo_interface__['geometry'] is None)
        ok_(feature.__geo_interface__['bbox'] is None)
开发者ID:123rohan123,项目名称:mapfish,代码行数:14,代码来源:test_postgis.py

示例5: BroadbandSpeedsController

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
class BroadbandSpeedsController(BaseController):
    readonly = False # if set to True, only GET is supported

    def __init__(self):
        self.protocol = Protocol(Session, BroadbandSpeed, self.readonly)

    @geojsonify
    def index(self, format='json'):
        """GET /: return all features."""
        # If no filter argument is passed to the protocol index method
        # then the default MapFish filter is used.
        #
        # If you need your own filter with application-specific params 
        # taken into acount, create your own filter and pass it to the
        # protocol read method.
        #
        # E.g.
        #
        # from sqlalchemy.sql import and_
        #
        # default_filter = create_default_filter(request, BroadbandSpeed)
        # filter = and_(default_filter, BroadbandSpeed.columname.ilike('%value%'))
        # return self.protocol.read(request, filter=filter)
        default_filter = create_default_filter(request, BroadbandSpeed)

        if "zones_f" in request.params:
            #zones will be a javascript list
            zones_q = request.params["zones_f"].split(",")
            #zones = Session.query(functions.geometry_type(functions.collect(Zone.geom))).filter(and_(Zone.zone_general.in_(zones_q),
            #                                                                                       Zone.geom != None)).scalar()
            zones = Session.query(functions.union(Zone.geom)).filter(Zone.zone_general.in_(zones_q)).first()
            filter = and_(default_filter, BroadbandSpeed.geom.within(zones))
        else:
            filter = default_filter

        if format != 'json':
            abort(404)
        return self.protocol.read(request, filter=filter)

    @geojsonify
    def show(self, id, format='json'):
        """GET /id: Show a specific feature."""
        if format != 'json':
            abort(404)
        return self.protocol.read(request, response, id=id)

    #@geojsonify
    #def create(self):
    #    """POST /: Create a new feature."""
    #    return self.protocol.create(request, response)
    #
    #@geojsonify
    #def update(self, id):
    #    """PUT /id: Update an existing feature."""
    #    return self.protocol.update(request, response, id)
    #
    #def delete(self, id):
    #    """DELETE /id: Delete an existing feature."""
    #    return self.protocol.delete(request, response, id)

    def count(self):
        """GET /count: Count all features."""
        return self.protocol.count(request)
开发者ID:gocodeboulder,项目名称:hotspots-mapfish,代码行数:65,代码来源:broadband_speeds.py

示例6: test_protocol_read_one_fails

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import read [as 别名]
 def test_protocol_read_one_fails(self):
     """Try to get a single point with a wrong primary key"""
     proto = Protocol(session, Spot)
     
     proto.read(FakeRequest({}), id=-1)
开发者ID:123rohan123,项目名称:mapfish,代码行数:7,代码来源:test_postgis.py


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