Ejemplo n.º 1
0
    def load(cls, user_email):
        with cls.lock:
            user = cls.users.get(user_email)
            if user:
                return user

            # TODO, dbconn should be outside the lock.
            # TODO: set up a db conn pool

            result = None
            db = db_conn(app.config['DB_NAME'],
                         app.config['DB_USERNAME'],
                         app.config['DB_PASSWORD'])
            if not db:
                return None

            userdata = db_load_user(db, user_email)
            if userdata:
                result = User(user_email = userdata["user_email"])

            db_disconn(db)
            cls.users[user_email] = result
            return result
Ejemplo n.º 2
0
def conn_to_db():
    g.db = db_conn(app.config['DB_NAME'],
                   app.config['DB_USERNAME'],
                   app.config['DB_PASSWORD'])