Пример #1
0
def setup_server(mod):
    # clear unwanted state
    web.ctx.clear()

    server._infobase = None  # clear earlier reference, if any.
    server.get_site("test")  # initialize server._infobase
    mod.site = server._infobase.create("test")  # create a new site
Пример #2
0
def setup_server(mod):
    # clear unwanted state
    web.ctx.clear()
    
    server._infobase = None # clear earlier reference, if any.
    server.get_site("test") # initialize server._infobase
    mod.site = server._infobase.create("test") # create a new site
Пример #3
0
def setup_module(module):
    monkey_patch_browser()

    infogami.config.site = "infogami.org"
    infogami.config.db_parameters = web.config.db_parameters = db_parameters

    server.get_site("infogami.org") # to initialize db

    module.db = server._infobase.store.db
    module.db.printing = False
    module.t = db.transaction()

    infogami._setup()
Пример #4
0
def setup_module(module):
    monkey_patch_browser()

    infogami.config.site = "infogami.org"
    infogami.config.db_parameters = web.config.db_parameters = db_parameters

    server.get_site("infogami.org")  # to initialize db

    module.db = server._infobase.store.db
    module.db.printing = False
    module.t = module.db.transaction()

    infogami._setup()
Пример #5
0
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")
Пример #6
0
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")
Пример #7
0
def setup_event_listener():
    logger.info("setting up infobase events for Open Library")

    ol = server.get_site('openlibrary.org')
    ib = server._infobase

    # Convert infobase event into generic eventer event
    ib.add_event_listener(lambda event: eventer.trigger("infobase.all", event))
Пример #8
0
def setup_event_listener():
    logger.info("setting up infobase events for Open Library")
    
    ol = server.get_site('openlibrary.org')
    ib = server._infobase

    # Convert infobase event into generic eventer event
    ib.add_event_listener(lambda event: eventer.trigger("infobase.all", event))
Пример #9
0
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")
Пример #10
0
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")
Пример #11
0
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")
Пример #12
0
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")
Пример #13
0
    def POST(self, key):
        i = web.input('key', _method='POST')
        page = web.ctx.site.get(key)

	assert ' ' not in i.key and i.key.startswith('/')

        web.transact()
	id = web.query('SELECT id FROM thing WHERE site_id=1 and key=$key', vars=locals())[0].id
        web.query("update thing set key=$i.key where id=$id", vars=locals())
        web.query("update datum set value=$i.key where thing_id=$id and key='key' and datatype=1", vars=locals())
        web.commit()
	from infogami.infobase.server import get_site
	site = get_site(config.site)
	site.thing_cache.clear()
	site.things_cache.clear()
	site.versions_cache.clear()
	web.seeother(i.key)
Пример #14
0
    def setUp(self):
        from infogami.infobase import server

        db = server.get_site("infogami.org").store.db

        self._t = db.transaction()
Пример #15
0
def get_db():
    site = server.get_site('openlibrary.org')
    return site.store.db
Пример #16
0
 def GET(self, sitename):
     global most_recent_change
     if most_recent_change is None:
         site = server.get_site('openlibrary.org')
         most_recent_change = site.versions({'limit': 1})[0]
     return most_recent_change
Пример #17
0
    def setUp(self):
        from infogami.infobase import server
        db = server.get_site('infogami.org').store.db

        self._t = db.transaction()
Пример #18
0
 def GET(self, sitename):
     global most_recent_change
     if most_recent_change is None:
         site = server.get_site('openlibrary.org')
         most_recent_change = site.versions({'limit': 1})[0]
     return most_recent_change
Пример #19
0
def get_db():
    site = server.get_site('openlibrary.org')
    return site.store.db