Пример #1
0
    def put(self, lab_id):
        #lab = Lab.objects(__raw__={"_id": ObjectId(lab_id)})[0]
        lab = Lab.getLabById(lab_id)
        #print(self.request.arguments)
        for field in self.request.arguments:
            lab[field] = self.get_body_argument(field)

        print 'updated lab ' + lab_id
        print lab.to_dict()

        lab.save()
        self.finish({'updated_lab': lab.to_client()})
Пример #2
0
    def get(self, _id, param=None):
        # get the specific lab passed from ID passed in the URL
        lab = Lab.getLabById(_id)
        if lab:
            # if further param/field is present
            if param:
                try:
                    # filter by it
                    self.finish({param: lab[param]})
                except KeyError:
                    # else invalid field
                    self.finish({'error': 'Invalid field attribute'})

            else:
                self.finish(lab.to_client())
        else:
            self.set_status(404)
            self.finish({"error": "Lab not found"})