def init_plugin(): """Initialize infobase plugin.""" from infogami.infobase import common, dbstore, server, logger dbstore.default_schema = schema.get_schema() 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(logger.Logger(config.writelog)) ib.add_event_listener(invalidate_most_recent_change) if ol: # install custom indexer #XXX-Anand: this might create some trouble. Commenting out. # ol.store.indexer = Indexer() if config.get('http_listeners'): ol.add_trigger(None, http_notify) # 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")
def init_plugin(): """Initialize infobase plugin.""" from infogami.infobase import common, dbstore, server, logger dbstore.default_schema = schema.get_schema() 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(logger.Logger(config.writelog)) ib.add_event_listener(invalidate_most_recent_change) if ol: if config.get('http_listeners'): ol.add_trigger(None, http_notify) if config.get('booklog'): global booklogger booklogger = logger.Logger(config.booklog) ol.add_trigger('/type/edition', write_booklog) ol.add_trigger('/type/author', write_booklog2) # 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")
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) 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")