def __init__(self, config): self.secret_key = config["secret_key"] self.db_autoflush = config["db"].get("autoflush") self.site_title = config.get("site_title") or "Lodge It" self.config = config self.attach_config = config["attachments"] # prepare the upload directory if not os.path.isdir(self.attach_config["upload_folder"]): os.makedirs(self.attach_config["upload_folder"]) #: bind metadata, create engine and create all tables self.engine = engine = create_engine(config["db"]["uri"], convert_unicode=True) db.metadata.bind = engine if self.config["db"]["create_all"]: db.metadata.create_all(engine) #: jinja_environment update jinja_environment.globals.update({ 'i18n_languages': i18n.list_languages()}) jinja_environment.filters.update({ 'datetimeformat': i18n.format_datetime}) jinja_environment.install_null_translations() #: bind the application to the current context local self.bind_to_context() self.cleanup_callbacks = (db.session.close, _local_manager.cleanup, self.bind_to_context)
def __init__(self, dburi, secret_key): self.secret_key = secret_key #: bind metadata, create engine and create all tables self.engine = engine = create_engine(dburi, convert_unicode=True) metadata.bind = engine metadata.create_all(engine) #: jinja_environment update jinja_environment.globals.update(i18n_languages=i18n.list_languages()) jinja_environment.filters.update(datetimeformat=i18n.format_datetime) jinja_environment.install_null_translations() #: bind the application to the current context local self.bind_to_context()
def __init__(self, dburi, secret_key): self.secret_key = secret_key #: bind metadata, create engine and create all tables self.engine = engine = create_engine(dburi, convert_unicode=True) db.metadata.bind = engine db.metadata.create_all(engine, [Paste.__table__]) #: jinja_environment update jinja_environment.globals.update({ 'i18n_languages': i18n.list_languages()}) jinja_environment.filters.update({ 'datetimeformat': i18n.format_datetime}) jinja_environment.install_null_translations() #: bind the application to the current context local self.bind_to_context() self.cleanup_callbacks = (db.session.close, _local_manager.cleanup, self.bind_to_context)
def __init__(self, dburi, secret_key): self.secret_key = secret_key #: bind metadata, create engine and create all tables self.engine = engine = create_engine(dburi, convert_unicode=True) db.metadata.bind = engine db.metadata.create_all(engine, [Paste.__table__]) #: jinja_environment update jinja_environment.globals.update( {'i18n_languages': i18n.list_languages()}) jinja_environment.filters.update( {'datetimeformat': i18n.format_datetime}) jinja_environment.install_null_translations() #: bind the application to the current context local self.bind_to_context() self.cleanup_callbacks = (db.session.close, _local_manager.cleanup, self.bind_to_context)