将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)
这不是很干净,因为我引发异常以强制阻止删除请求。