本文整理汇总了Python中mapfish.protocol.Protocol.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Protocol.delete方法的具体用法?Python Protocol.delete怎么用?Python Protocol.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mapfish.protocol.Protocol
的用法示例。
在下文中一共展示了Protocol.delete方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_protocol_delete
# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import delete [as 别名]
def test_protocol_delete(self):
"""Delete an existing point"""
proto = Protocol(session, Spot)
id = 1
request = FakeRequest({})
response = FakeResponse()
proto.delete(request, response, id)
eq_(response.status, 204)
spot = session.query(Spot).get(id)
ok_(spot is None)
示例2: ParkingMetersController
# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import delete [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)
示例3: test_protocol_delete_fails
# 需要导入模块: from mapfish.protocol import Protocol [as 别名]
# 或者: from mapfish.protocol.Protocol import delete [as 别名]
def test_protocol_delete_fails(self):
"""Try to delete a not-existing point"""
proto = Protocol(session, Spot)
proto.delete(FakeRequest({}), FakeResponse(), -1)