예제 #1
0
파일: root.py 프로젝트: clsdaniel/tg2docs
    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")
예제 #2
0
파일: root.py 프로젝트: clsdaniel/tg2docs
    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")
예제 #3
0
파일: root.py 프로젝트: clsdaniel/tg2docs
 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")
예제 #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")
예제 #5
0
파일: root.py 프로젝트: clsdaniel/tg2docs
 def list(self):
     """List all movies in the database"""
     return dict(movies=DBSession.query(Movie),
         page='ToscaSample Movie list')
예제 #6
0
 def decolist(self):
     """List and paginate all movies in the database using the
     paginate() decorator."""
     movies = DBSession.query(Movie)
     return dict(movies=movies, page='ToscaSample Movie list')
예제 #7
0
 def list(self, page=1):
     """List and paginate all movies in the database"""
     movies = DBSession.query(Movie)
     currentPage = paginate.Page(movies, page, items_per_page=5)
     return dict(movies=currentPage.items, page='ToscaSample Movie list', 
                 currentPage=currentPage)
예제 #8
0
파일: root.py 프로젝트: clsdaniel/tg2docs
 def list(self):
     """List all movies in the database"""
     return dict(movies=DBSession.query(Movie),
                 page='ToscaSample Movie list')