def post(self, id=None):
try:
if id:
raise NotFoundError() # 404
if app.service.enforcesAccess and not app.acl.get_permission(app.acl.get_user()).x:
raise UnauthorizedError()
objs = json.loads(request.data)
if not isinstance(objs, list):
raise ParseError()
pids = app.db.get_service().providesCollectionPids
if pids:
objs = [CollectionObject(**obj.update({'id': app.mint.get_id(CollectionObject)})) if isinstance(obj, dict) else obj for obj in objs]
if app.db.ask_collection([obj.id for obj in objs]):
raise ConflictError()
app.db.set_collection(objs)
return jsonify(objs), 201
except (NotFoundError, DBError, UnauthorizedError, ConflictError):
raise
except:
raise ParseError() # 400
评论列表
文章目录