Beispiel #1
0
    def create(self, **kw):
        movie = Movie()
        movie.title = kw['title']
        movie.year = kw['year']
        movie.release_date = kw['release_date']
        movie.description = kw['description']
        movie.genre = kw['genre']
        
        #save the filename to the database
        movie.picture_filename = kw['picture_filename'].filename
        DBSession.add(movie)
        DBSession.flush()

        #write the picture file to the public directory
        movie_path = os.path.join(movies_dirname, str(movie.id))
        try:
            os.makedirs(movie_path)
        except OSError:
            #ignore if the folder already exists
            pass
            
        movie_path = os.path.join(movie_path, movie.picture_filename)
        f = file(movie_path, "w")
        f.write(kw['picture_filename'].value)
        f.close()
        
        flash("Movie was successfully created.")
        redirect("list")
Beispiel #2
0
    def create(self, **kw):
        movie = Movie()
        movie.title = kw['title']
        movie.year = kw['year']
        movie.release_date = kw['release_date']
        movie.description = kw['description']
        movie.genre = kw['genre']

        #save the filename to the database
        movie.picture_filename = kw['picture_filename'].filename
        DBSession.add(movie)
        DBSession.flush()

        #write the picture file to the public directory
        movie_path = os.path.join(movies_dirname, str(movie.id))
        try:
            os.makedirs(movie_path)
        except OSError:
            #ignore if the folder already exists
            pass

        movie_path = os.path.join(movie_path, movie.picture_filename)
        f = file(movie_path, "w")
        f.write(kw['picture_filename'].value)
        f.close()

        flash("Movie was successfully created.")
        redirect("list")
Beispiel #3
0
 def create(self, **kw):
     """Create a movie object and save it to the database."""
     movie = Movie()
     movie.title = kw['title']
     movie.year = kw['year']
     movie.release_date = kw['release_date']
     movie.description = kw['description']
     movie.genre = kw['genre']
     DBSession.add(movie)
     flash("Movie was successfully created.")
     redirect("list")
Beispiel #4
0
 def create(self, **kw):
     """Create a movie object and save it to the database."""
     movie = Movie()
     movie.title = kw['title']
     movie.year = kw['year']
     movie.release_date = kw['release_date']
     movie.description = kw['description']
     movie.genre = kw['genre']
     DBSession.add(movie)
     flash("Movie was successfully created.")
     redirect("list")