def get_db(): """Opens a new database connection if there is none yet for the current application context. """ if not hasattr(g, 'connection'): g.connection = db_connect() return g.connection
def __init__(self, dev_session=None): if dev_session: self.db_session = dev_session else: self.db_session = db_connect() self.subs = SUBS