]> git.datanom.net - pwp.git/blobdiff - app/__init__.py
Half way through migration away from sqlalchemy
[pwp.git] / app / __init__.py
index e5fd11d1656448c74acb225f562993c3cb306187..195f77b57ee7a97f67a0134bffe8e198f1f0b859 100644 (file)
@@ -1,9 +1,8 @@
 from flask import Flask
 from flask_bootstrap import Bootstrap
-from config import ADMINS, MAIL_SERVER, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
+from config import DB_DRIVER, DB_PASSWORD, DB_USER, DB_DATABASE, DB_HOST, DB_PORT
 from flask_login import LoginManager
 from flask_wtf.csrf import CSRFProtect
-
 app = Flask(__name__)
 app.config.from_object('config')
 lm = LoginManager()
@@ -13,25 +12,8 @@ bootstrap = Bootstrap(app)
 csrf = CSRFProtect()
 csrf.init_app(app)
 
-if not app.debug:
-    import logging
-
-    from logging.handlers import SMTPHandler, RotatingFileHandler
-    credentials = None
-    if MAIL_USERNAME or MAIL_PASSWORD:
-        credentials = (MAIL_USERNAME, MAIL_PASSWORD)
-    mail_handler = SMTPHandler((MAIL_SERVER, MAIL_PORT), 'no-reply@' + MAIL_SERVER, ADMINS, 'PWP failure', credentials)
-    mail_handler.setLevel(logging.ERROR)
-    mail_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
-    app.logger.addHandler(mail_handler)
-
-    file_handler = RotatingFileHandler('log/pwp.log', 'a', 1 * 1024 * 1024, 10)
-    file_handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno)d]'))
-    app.logger.addHandler(file_handler)
-
-    app.logger.setLevel(logging.INFO)
-    file_handler.setLevel(logging.INFO)
-    app.logger.info('pwp startup')
+from db import DB
+db = DB(DB_PASSWORD, DB_DRIVER, DB_USER, DB_DATABASE, DB_HOST, DB_PORT)
 
 from app import views, models
 lm.anonymous_user = models.MyAnonymous
This page took 0.031575 seconds and 5 git commands to generate.