Exemple #1
0
    def _action_create_boar(self, context, boar_dict):
        for key in boar_dict.keys():
            if key not in self._boar_keys:
                #raise exception.Invalid('Invalid key in body')
                msg = "Invalid key  %s in body" % key
                raise webob.exc.HTTPBadRequest(explanation=msg)

        boar_obj = objects.Boar(context)
        boar_obj.update(boar_dict)
        result = boar_obj.create(context) 
        return {"boar": self._format_boar(result)}
Exemple #2
0
 def get_all(self):
     boars = objects.Boar().list(
             pecan.request.context)
     result = [self._format_boar(boar) for boar in boars]
     return {'boars': result}
Exemple #3
0
 def get_one(self,id):
     boar = objects.Boar().get_by_id(pecan.request.context,id)
     result = self._format_boar(boar)
     return {'boar': result}