def newGenre():
    if request.method == 'POST':
        newGenre = Genre(name=request.form['name'])
        newGenre.recordOwner = login_session['profile']['email']
        session.add(newGenre)
        flash('New Genre %s Successfully Created.' % newGenre.name)
        session.commit()
        return redirect(url_for('showGenre'))
    else:
        return render_template('newgenre.html')
示例#2
0
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()


# Biography
genre1 = Genre(name="Biography")
genre1.recordOwner = "*****@*****.**"
session.add(genre1)
session.commit()
# Book 1
book1 = Audiobook(title="Proud: My Fight for an Unlikely American Dream",
                  duration="9h:12m", price="$29.65", genre=genre1)
book1.recordOwner = "*****@*****.**"
session.add(book1)
session.commit()
# Author 1
author1 = Author(name="Ibtihaj Muhammad, Lori L. Tharps",
                 audiobook=book1)

session.add(author1)
session.commit()
# Narrator 1