def put(self, id): data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() owner_required = 'owner_id' in data self.attach_owner(None, required=owner_required) return super(QuestionApi, self).put(id)
def put(self, id, userid): data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() owner_required = 'owner_id' in data self.attach_owner(userid, required=owner_required) return super(DataProviderApi, self).put(id, with_owner=True)
def post(self, userid): utils.check_owner(userid) data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() self.attach_owner(userid) try: return super(EventApi, self).post(with_owner=True) except sqlalchemy.exc.IntegrityError: raise EventNameRequired()
def post(self, userid): data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() self.attach_owner(userid) try: return super(DataProviderApi, self).post(with_owner=True) except sqlalchemy.exc.IntegrityError as e: logger.error(e) raise DataProviderNameRequired()
def put(self, id, userid): data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() event, id = db.get_event(id) if event is None: raise exc.NotFound() utils.check_owner(event.owner_id) owner_required = 'owner_id' in data self.attach_owner(userid, required=owner_required) return super(EventApi, self).put(id, with_owner=True)
def post(self, userid, eventid): data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() event = self.attach_event(eventid, required=False) if event: self.attach_owner(event.owner_id) else: self.attach_owner(userid) try: return super(QuestionApi, self).post() except sqlalchemy.exc.IntegrityError as e: logger.error(e) raise QuestionNameRequired()
def put(self, id, **kwargs): session = flask.g.session data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() try: result = sautils.get_one(session, self.base_resource, id, self.alternate_key) for attach, value in self.attachments.items(): setattr(result, attach, value) result.update(**data) session.commit() return jsonp.jsonify(result.to_dict(**kwargs)), 200, {} except sa_exc.NoResultFound: raise exc.NotFound()
def post(self, **kwargs): session = flask.g.session data = flaskutils.json_request_data(flask.request.data) if not data: raise exc.RequiresBody() try: result = self.base_resource(**data) for attach, value in self.attachments.items(): setattr(result, attach, value) session.add(result) session.commit() return jsonp.jsonify(result.to_dict(**kwargs)), 201, {} except TypeError as e: logger.error(e) session.rollback() raise exc.InvalidInput
def json_stuff(): flaskutils.json_request_data(flask.request.data)