数据检索parse.com

时间:2017-03-17 19:49:08

标签: android parse-platform android-recyclerview

我正在开发一个Android应用程序。因为我已经创建了表产品 列标题,Image1,Image2等 我想在回收站视图或卡片视图中显示它。包括图像。我怎么能这样做......?

class table_basics(Resource):

    def get(self, cownumber):
        master_animal_query = Master_animal.query.get_or_404(cownumber)
        #Serialize the query results in the JSON API format
        result = schemaMaster.dump(master_animal_query).data
        return result

    def post(self):
        raw_dict = request.get_json(force=True)
        master_dict = raw_dict['data']['attributes']
        try:
                #Validate the data or raise a Validation error if
                schemaMaster.validate(master_dict)
                #Create a master object with the API data recieved
                master = Master_animal(cownumber=master_dict['cownumber'], weight=master_dict['weight'],height=master_dict['height'],eartag=master_dict['eartag'],eid=master_dict['eid'],sex=master_dict['sex'],pasturenumber=master_dict['pasturenumber'],breed=master_dict['breed'],status=master_dict['status'],trial=master_dict['trial'],herd=master_dict['herd'],animaltype=master_dict['animaltype'])
                master.add(master)
                query = Master_animal.query.all()
                results = schemaMaster.dump(query, many = True).data
                return results, 201


        except ValidationError as err:
                resp = jsonify({"error": err.messages})
                resp.status_code = 403
                return resp               

        except SQLAlchemyError as e:
                db.session.rollback()
                resp = jsonify({"error": str(e)})
                resp.status_code = 403
                return resp

    def patch(self, cownumber):
        master_animal_query = Master_animal.query.get_or_404(cownumber)
        raw_dict = request.get_json(force=True)
        master_dict = raw_dict['data']['attributes']
        try:
            schemaMaster.validate(master_dict)
            for key, value in master_dict.items():
                setattr(master_animal_query, key, value)

            master_animal_query.update()
            return self.get(cownumber)

        except ValidationError as err:
            resp = jsonify({"error": err.messages})
            resp.status_code = 401
            return resp

        except SQLAlchemyError as e:
            db.session.rollback()
            resp = jsonify({"error": str(e)})
            resp.status_code = 401
            return resp

0 个答案:

没有答案