Beispiel #1
0
def initialize_database(autoinitialize=True):
    db_url = Configuration.database_url()
    if autoinitialize:
        SessionManager.initialize(db_url)
    session_factory = SessionManager.sessionmaker(db_url)
    _db = flask_scoped_session(session_factory, app)
    app._db = _db

    Configuration.load(_db)
    testing = 'TESTING' in os.environ
    log_level = LogConfiguration.initialize(_db, testing=testing)
    if app.debug is None:
        debug = log_level == 'DEBUG'
        app.debug = debug
    else:
        debug = app.debug
    app.config['DEBUG'] = debug
    _db.commit()
    app.log = logging.getLogger("Metadata web app")
    app.log.info("Application debug mode: %r", app.debug)
    for logger in logging.getLogger().handlers:
        app.log.info("Logs are going to %r", logger)

    # Register an error handler that logs exceptions through the
    # normal logging process and tries to turn them into Problem
    # Detail Documents.
    h = ErrorHandler(app, app.config['DEBUG'])

    @app.errorhandler(Exception)
    def exception_handler(exception):
        return h.handle(exception)
def initialize_database(autoinitialize=True):
    db_url = Configuration.database_url()
    if autoinitialize:
        SessionManager.initialize(db_url)
    session_factory = SessionManager.sessionmaker(db_url)
    _db = flask_scoped_session(session_factory, app)
    app._db = _db

    Configuration.load(_db)
    testing = 'TESTING' in os.environ
    log_level = LogConfiguration.initialize(_db, testing=testing)
    if app.debug is None:
        debug = log_level == 'DEBUG'
        app.debug = debug
    else:
        debug = app.debug
    app.config['DEBUG'] = debug
    _db.commit()
    app.log = logging.getLogger("Metadata web app")
    app.log.info("Application debug mode: %r", app.debug)
    for logger in logging.getLogger().handlers:
        app.log.info("Logs are going to %r", logger)

    # Register an error handler that logs exceptions through the
    # normal logging process and tries to turn them into Problem
    # Detail Documents.
    h = ErrorHandler(app, app.config['DEBUG'])
    @app.errorhandler(Exception)
    def exception_handler(exception):
        return h.handle(exception)
Beispiel #3
0
 def load(cls):
     CoreConfiguration.load()
     config = CoreConfiguration.instance
     if not config.get(cls.POLICIES):
         config[cls.POLICIES] = {}
     if not config[cls.POLICIES].get(cls.ANALYTICS_POLICY):
         config[cls.POLICIES][cls.ANALYTICS_POLICY] = Analytics.initialize(["api.local_analytics_provuder"], config)
     cls.instance = config
Beispiel #4
0
 def load(cls):
     CoreConfiguration.load()
     cls.instance = CoreConfiguration.instance
Beispiel #5
0
 def load(cls, _db=None):
     CoreConfiguration.load(_db)
     cls.instance = CoreConfiguration.instance
     return cls.instance
Beispiel #6
0
 def initialize(cls, _db):
     cls.db = _db
     Configuration.load(cls.db)
     cls.log = logging.getLogger("Metadata web app")
Beispiel #7
0
 def load(cls, _db=None):
     CoreConfiguration.load(_db)
     cls.instance = CoreConfiguration.instance
     return cls.instance
    ConfigurationSetting,
    ExternalIntegration as EI,
    get_one_or_create,
    production_session,
)

log = logging.getLogger(name="Metadata Wrangler configuration import")


def log_import(integration_or_setting):
    log.info("CREATED: %r" % integration_or_setting)


_db = production_session()
try:
    Configuration.load()

    shadowcat_conf = Configuration.integration('Shadowcat')
    if shadowcat_conf and shadowcat_conf.get('url'):
        shadowcat = EI(name=EI.NYPL_SHADOWCAT,
                       protocol=EI.NYPL_SHADOWCAT,
                       goal=EI.METADATA_GOAL)
        _db.add(shadowcat)
        shadowcat.url = shadowcat_conf.get('url')
        log_import(shadowcat)

    content_cafe_conf = Configuration.integration('Content Cafe')
    if content_cafe_conf:
        content_cafe = EI(name=EI.CONTENT_CAFE,
                          protocol=EI.CONTENT_CAFE,
                          goal=EI.METADATA_GOAL)
from core.model import (
    ConfigurationSetting,
    ExternalIntegration as EI,
    get_one_or_create,
    production_session,
)

log = logging.getLogger(name="Metadata Wrangler configuration import")

def log_import(integration_or_setting):
    log.info("CREATED: %r" % integration_or_setting)


_db = production_session()
try:
    Configuration.load()

    shadowcat_conf = Configuration.integration('Shadowcat')
    if shadowcat_conf and shadowcat_conf.get('url'):
        shadowcat = EI(
            name=EI.NYPL_SHADOWCAT,
            protocol=EI.NYPL_SHADOWCAT,
            goal=EI.METADATA_GOAL
        )
        _db.add(shadowcat)
        shadowcat.url = shadowcat_conf.get('url')
        log_import(shadowcat)

    content_cafe_conf = Configuration.integration('Content Cafe')
    if content_cafe_conf:
        content_cafe = EI(