def put(self, instance_id):
"""
Update a model with data given in the request body. JSON format is
expected. Model performs the validation automatically when fields are
modified.
"""
try:
data = self.get_arguments()
instance = self.get_model_or_404(instance_id)
self.check_update_permissions(instance.serialize(), data)
instance.update(data)
return instance.serialize(), 200
except StatementError:
return {"error": "Wrong id format"}, 400
except TypeError as exception:
current_app.logger.error(str(exception))
return {"error": str(exception)}, 400
except IntegrityError as exception:
current_app.logger.error(str(exception))
return {"error": str(exception)}, 400
except StatementError as exception:
current_app.logger.error(str(exception))
return {"error": str(exception)}, 400
except permissions.PermissionDenied:
abort(403)
评论列表
文章目录