将 DELETE 请求转换为 UPDATE 的正确方法是什么?
我正在做这样的事情:
api_manager.create_api(News,
methods=['GET', 'POST', 'DELETE', 'PUT'],
preprocessors={'DELETE': [pre_delete_news]})
def pre_delete_news(instance_id=None, **kw):
# Set the deleted flag
db.engine.execute("SET delete = True FROM news WHERE id = %d" % instance_id)
# Block the DELETE request by raising an exception
raise ProcessingException(description='Delete successfull', code=418)
这不是很干净,因为我引发了一个异常来强制阻止删除请求。