views.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:perseids-manifold 作者: RDACollectionsWG 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号