Пример #1
0
    def post(self):
        if 'owned' in self.request.url:
            self.response.set_status(405)
            return
        
        logging.info("Received new place to save: " + self.request.body)
        # TODO: only an admin can create new places
#         auth = self.request.headers.get("Authorization")
#         if auth is None or len(auth) < 1:
#             auth = self.request.cookies.get("user")
#         if auth is None:
#             user_id = None
#         else:
#             user_id = logic.get_current_userid(auth)
#         if user_id is None:
#             self.response.set_status(403)
#             self.response.write("You must login first!")
#             return
        
        
        body = json.loads(self.request.body)
        try:
            place = Place.from_json(body)
        except TypeError, e:
            self.response.set_status(400)
            self.response.write(str(e))
            return
Пример #2
0
    def put(self, pid):
        if 'owner' in self.request.url:
            self.response.set_status(405) 
            return
#         auth = self.request.headers.get("Authorization")
#         if auth is None or len(auth) < 1:
#             auth = self.request.cookies.get("user")
#         if auth is None:
#             user_id = None
#         else:
#             user_id = logic.get_current_userid(auth)
#         if user_id is None:
#             self.response.set_status(403)
#             self.response.write("You must login first!")
#             return

        body = json.loads(self.request.body)
        try:
            place = Place.from_json(body)
        except TypeError, e:
            self.response.set_status(400)
            self.response.write(str(e))
            return