コード例 #1
0
    def post(self):
        upload = self.get_uploads()[0]
        recipe_id = self.request.get('recipe_id')
        recipe = Recipe.get_by_id(long(recipe_id))
        # # user_id = self.session.get('user_id')
        author_comments = self.request.get('author_comments')
        user_id = self.request.get('user_id')
        user = User.get_by_id(user_id)

        #img = images.resize(img, 200, 200)
        # if len(upload) >0:
        #     recipe.photos.append(Photo(
        #     blob_key = upload[0].key(),
        #     filename= upload[0].filename,
        # ))
        recipe.put()

        history = History()
        history.recipe_name = recipe.name
        history.author_comments = author_comments
        history.FromAndroid = True
        history.recipe_id = str(recipe.key.id())
        history.tags = recipe.tags
        history.recipe_author= user.user_name
        history.recipe_description= recipe.description
        history.recipe_authorID = user_id

        history.photos.append(Photo(
            blob_key = upload.key(),
            filename= "hi",
        ))
        # if len(upload) >0:
        #     history.photos.append(Photo(
        #         # blob_key = upload[0].key(),
        #         # filename= upload[0].filename,
        #         blob_key = upload.key(),
        #         filename= "hi",
        #     ))
        history.put()
        time.sleep(1)