def put(self): tool_user, db_user = ADayThere.tool_user() if not tool_user: self.response.status = 401 return data = json.loads(self.request.body) day = Day() day.userid = db_user.user_id day.name = db_user.name day.full_locality = data["full_locality"] day.title = data["title"] day.description = data["description"] if isinstance(data["keywords"], basestring): if "," in data["keywords"]: day.keywords = data["keywords"].split(",") else: day.keywords = data["keywords"].split(" ") else: day.keywords = data["keywords"] for keyword in day.keywords: Keywords.add_if_missing(keyword) day.places = [] for place in data["places"]: p = Place() p.name = place["name"] p.comment = place["comment"] p.location = Location() p.location.latitude = str(place["location"]["latitude"]) p.location.longitude = str(place["location"]["longitude"]) p.location.vicinity = place["vicinity"] day.places.append(p) day.photos = [] for photo in data["photos"]: day_photo = DayPhoto() day_photo.title = photo["title"] day_photo.description = photo["description"] day.photos.append(day_photo) photo_query = Photos.query_photo(db_user.user_id, photo["title"]) pq = photo_query.get() if pq is not None: cnt = pq.used_by.count(day.title) if cnt == 0: pq.used_by.append(day.title) pq.put() day.put() KeywordsDayList.add_keywords(day) Words.add_words(day.title, day.description, day.key, day.full_locality) self.response.status = 200