Exemplo n.º 1
0
 def get(self, model_name):
     model = self.get_model(model_name)
     if model is None:
         return
     query = model.all().filter('user_id =', self.user_id)
     items = [item.get_dict() for item in query.fetch(1000)]
     json_response(self.response, items)
Exemplo n.º 2
0
 def get(self, model_name):
     model = self.get_model(model_name)
     if model is None:
         return
     query = model.all().filter('user_id =', self.user_id)
     items = [item.get_dict() for item in query.fetch(1000)]
     json_response(self.response, items)
Exemplo n.º 3
0
 def post(self, model_name):
     model = self.get_model(model_name)
     if model is None:
         return
     data = json.loads(self.request.body)
     item = model(user_id=self.user_id)
     item.set_dict(data)
     item.put()
     json_response(self.response, item.get_dict())
Exemplo n.º 4
0
 def post(self, model_name):
     model = self.get_model(model_name)
     if model is None:
         return
     data = json.loads(self.request.body)
     item = model(user_id=self.user_id)
     item.set_dict(data)
     item.put()
     json_response(self.response, item.get_dict())
Exemplo n.º 5
0
    def post(self, model_name):
        model = self.get_model(model_name)
        if model is None:
            return

        # HACK - How else to initialize properties ONLY in the case
        # where a model is being created.
        if hasattr(model, 'set_defaults'):
            model.set_defaults()

        data = json.loads(self.request.body)
        item = model(user_id=self.user_id)
        item.set_dict(data)
        item.put()
        json_response(self.response, item.get_dict())
Exemplo n.º 6
0
    def put(self, model_name, id):
        item = self.get_item(model_name, id)
        if not item:
            return

        data = json.loads(self.request.body)
        if item.user_id != self.user_id:
            self.error(403)
            self.response.out.write(
                json.dumps({'status': "Write permission failure."}))
            return

        item.set_dict(data)
        item.put()
        json_response(self.response, item.to_dict())
Exemplo n.º 7
0
    def put(self, model_name, id):
        item = self.get_item(model_name, id)
        if not item:
            return

        data = json.loads(self.request.body)
        if item.user_id != self.user_id:
            self.error(403)
            self.response.out.write(json.dumps({
                'status': "Write permission failure."
                }))
            return

        item.set_dict(data)
        item.put()
        json_response(self.response, item.to_dict())
Exemplo n.º 8
0
    def get(self, model_name):
        model = self.get_model(model_name)
        if model is None:
            return

        query = model.all()

        for property_name in self.request.arguments():
            value = self.request.get(property_name)
            if '*' == value[-1]:
                filter_query_by_prefix(query, model, property_name, value[:-1])
            else:
                filter_query_by_value(query, model, property_name, value)

        results = query.fetch(1000)
        logging.info("Found [%i] %s's" % (len(results), model_name))
        items = [item.get_dict() for item in results]
        json_response(self.response, items)
Exemplo n.º 9
0
 def get(self, model_name, id):
     item = self.get_item(model_name, id)
     if not item:
         return
     json_response(self.response, item.get_dict())