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


Python Protocol.update方法代码示例

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


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

示例1: test_protocol_update_fails

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import update [as 别名]
 def test_protocol_update_fails(self):
     """Try to update a not-existing feature"""
     proto = Protocol(session, Spot)
     id = -1
     
     request = FakeRequest({})
     request.body = '{"type": "Feature", "id": ' + str(id) + ', "properties": {}, "geometry": {"type": "Point", "coordinates": [1, 1]}}'
     
     response = FakeResponse()
     proto.update(request, response, id)
开发者ID:123rohan123,项目名称:mapfish,代码行数:12,代码来源:test_postgis.py

示例2: ParkingMetersController

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

    def __init__(self):
        self.protocol = Protocol(Session, ParkingMeter, 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, ParkingMeter)
        # filter = and_(default_filter, ParkingMeter.columname.ilike('%value%'))
        # return self.protocol.read(request, filter=filter)
        if format != 'json':
            abort(404)
        response.headers['Access-Control-Allow-Origin'] = 'http://localhost:8000';
        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,代码行数:54,代码来源:parking_meters.py

示例3: test_protocol_update

# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import update [as 别名]
 def test_protocol_update(self):
     """Update an existing point"""
     proto = Protocol(session, Spot)
     id = 1
     
     request = FakeRequest({})
     request.body = '{"type": "Feature", "id": ' + str(id) + ', "properties": {}, "geometry": {"type": "Point", "coordinates": [1, 1]}}'
     
     response = FakeResponse()
     feature = proto.update(request, response, id)
     eq_(response.status, 201)
     eq_(feature.id, 1)
     eq_(feature.geometry.coordinates, (1.0, 1.0))
     
     spot = session.query(Spot).get(id)
     ok_(spot is not None)
     eq_(session.scalar(spot.spot_location.wkt), u'POINT(1 1)')
开发者ID:123rohan123,项目名称:mapfish,代码行数:19,代码来源:test_postgis.py


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