def init_plugin(): """Initialize infobase plugin.""" from infogami.infobase import common, dbstore, server, logger as infobase_logger dbstore.default_schema = schema.get_schema() # Replace infobase Indexer with OL custom Indexer dbstore.Indexer = OLIndexer if config.get('errorlog'): common.record_exception = lambda: save_error(config.errorlog, 'infobase') ol = server.get_site('openlibrary.org') ib = server._infobase if config.get('writelog'): ib.add_event_listener(infobase_logger.Logger(config.writelog)) ib.add_event_listener(invalidate_most_recent_change) # When setting up the dev instance, celery is not available. # Using DISABLE_CELERY environment variable to decide whether or not to trigger celery events. # DISABLE_CELERY will be set to true when setting up the dev instance. if os.getenv("DISABLE_CELERY", "").lower() != "true": ib.add_event_listener(notify_celery) setup_logging() if ol: # install custom indexer #XXX-Anand: this might create some trouble. Commenting out. # ol.store.indexer = Indexer() if config.get('http_listeners'): logger.info("setting up http listeners") ol.add_trigger(None, http_notify) ## memcache invalidator is not required now. It was added for future use. #_cache = config.get("cache", {}) #if _cache.get("type") == "memcache": # logger.info("setting up memcache invalidater") # ol.add_trigger(None, MemcacheInvalidater()) # hook to add count functionality server.app.add_mapping("/([^/]*)/count_editions_by_author", __name__ + ".count_editions_by_author") server.app.add_mapping("/([^/]*)/count_editions_by_work", __name__ + ".count_editions_by_work") server.app.add_mapping("/([^/]*)/count_edits_by_user", __name__ + ".count_edits_by_user") server.app.add_mapping("/([^/]*)/most_recent", __name__ + ".most_recent") server.app.add_mapping("/([^/]*)/clear_cache", __name__ + ".clear_cache") server.app.add_mapping("/([^/]*)/stats/(\d\d\d\d-\d\d-\d\d)", __name__ + ".stats") server.app.add_mapping("/([^/]*)/has_user", __name__ + ".has_user") server.app.add_mapping("/([^/]*)/olid_to_key", __name__ + ".olid_to_key") server.app.add_mapping("/_reload_config", __name__ + ".reload_config") server.app.add_mapping("/_inspect", __name__ + "._inspect")
def init_plugin(): """Initialize infobase plugin.""" from infogami.infobase import common, dbstore from infogami.infobase import logger as infobase_logger from infogami.infobase import server dbstore.default_schema = schema.get_schema() # Replace infobase Indexer with OL custom Indexer dbstore.Indexer = OLIndexer if config.get('errorlog'): common.record_exception = lambda: save_error( config.errorlog, 'infobase') # type: ignore[attr-defined] ol = server.get_site('openlibrary.org') ib = server._infobase if config.get('writelog'): ib.add_event_listener(infobase_logger.Logger(config.writelog)) ib.add_event_listener(invalidate_most_recent_change) setup_logging() if ol: # install custom indexer # XXX-Anand: this might create some trouble. Commenting out. # ol.store.indexer = Indexer() if config.get('http_listeners'): logger.info("setting up http listeners") ol.add_trigger(None, http_notify) # # memcache invalidator is not required now. It was added for future use. # _cache = config.get("cache", {}) # if _cache.get("type") == "memcache": # logger.info("setting up memcache invalidater") # ol.add_trigger(None, MemcacheInvalidater()) # hook to add count functionality server.app.add_mapping(r"/([^/]*)/count_editions_by_author", __name__ + ".count_editions_by_author") server.app.add_mapping(r"/([^/]*)/count_editions_by_work", __name__ + ".count_editions_by_work") server.app.add_mapping(r"/([^/]*)/count_edits_by_user", __name__ + ".count_edits_by_user") server.app.add_mapping(r"/([^/]*)/most_recent", __name__ + ".most_recent") server.app.add_mapping(r"/([^/]*)/clear_cache", __name__ + ".clear_cache") server.app.add_mapping(r"/([^/]*)/stats/(\d\d\d\d-\d\d-\d\d)", __name__ + ".stats") server.app.add_mapping(r"/([^/]*)/has_user", __name__ + ".has_user") server.app.add_mapping(r"/([^/]*)/olid_to_key", __name__ + ".olid_to_key") server.app.add_mapping(r"/_reload_config", __name__ + ".reload_config") server.app.add_mapping(r"/_inspect", __name__ + "._inspect")