Example #1
0
db = SQLAlchemy(app)
migrate = Migrate(app, db)

manager.add_command("db", MigrateCommand)

login_manager = LoginManager(app)
ldap_manager = LDAP3LoginManager(app)

login_manager.login_view = "login"
login_manager.login_message_category = "info"


# in the actual database this column is no primary key, but unfortunately
# SQLAlchemy accepty only tables that have a primary key column>
etherpad_store = db.Table("store",
    db.Column("key", db.Text(), primary_key=True),
    db.Column("value", db.Text()),
)


class AuthorizationError(Exception):
    pass


@app.errorhandler(AuthorizationError)
def handle_authorization_error(e):
    contact = current_app.config["CONTACT_EMAIL"]
    flash("You are not authorized to log in. Please contact %s for further "
          "information." % contact, "danger")
    return redirect(url_for("login"))