Given a DB engine return a DB session bound to that engine

def get_db_session(engine):
    "Given a DB engine return a DB session bound to that engine"

    db = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
    db.configure(bind=engine)
    db.autoflush = True

    return db