def regenerate_version_status_tree():
    for lang in [None, "he", "en"]:
        django_cache(action="set", cache_prefix='version_status_tree_api')(
            library.simplify_toc)(lang=lang if lang else "")
    if USE_VARNISH:
        for lang in ["he", "en"]:
            purge_url(u"{}/api/texts/version-status/tree/{}".format(
                FRONT_END_URL, lang))
        purge_url(u"{}/api/texts/version-status/tree/".format(FRONT_END_URL))
示例#2
0
def redo_bare_links_api(cat1, cat2):
    cat1idxs = library.get_indexes_in_category(cat1)
    cat2idxs = library.get_indexes_in_category(cat2)
    for c1idx in cat1idxs:
        print "bare_link_api:, Book: {}, Category: {}".format(c1idx, cat2)
        django_cache(action="set", cache_prefix='bare_link_api')(get_book_link_collection)(book=c1idx, cat=cat2)
    for c2idx in cat2idxs:
        print "bare_link_api:, Book: {}, Category: {}".format(c2idx, cat1)
        django_cache(action="set", cache_prefix='bare_link_api')(get_book_link_collection)(book=c2idx, cat=cat1)
def regenerate_bare_links_api(cat1, cat2):
    cat1idxs = library.get_indexes_in_category(cat1)
    cat2idxs = library.get_indexes_in_category(cat2)
    for c1idx in cat1idxs:
        print "bare_link_api:, Book: {}, Category: {}".format(c1idx, cat2)
        django_cache(action="set", cache_prefix='bare_link_api')(get_book_link_collection)(book=c1idx, cat=cat2)
    for c2idx in cat2idxs:
        print "bare_link_api:, Book: {}, Category: {}".format(c2idx, cat1)
        django_cache(action="set", cache_prefix='bare_link_api')(get_book_link_collection)(book=c2idx, cat=cat1)
示例#4
0
def reset_cached_api(request, apiurl):
    """
    This admin call gets the url of the original api that we wish to reset, backwards resolves that original function and gets its data back into cache
    :param request:
    :param apiurl:
    :return:
    """
    from undecorated import undecorated
    # from importlib import import_module
    try:
        match = resolve("/api/{}".format(apiurl))
        #mod = import_module(".".join(match.view_name.split(".")[:-1])) Dont actually need this, resolve gets us the func itself
        #func = mod.__getattribute__(match.func.func_name)

        if "django_cache" in match.func.func_dict:
            api_view = undecorated(match.func)
            redecorated_api_view = scache.django_cache(
                action="reset")(api_view)
            redecorated_api_view(request, *match.args, **match.kwargs)

            return HttpResponseRedirect("/api/{}".format(apiurl))
        else:
            raise Http404("API not in cache")

    except Resolver404 as re:
        logger.warn(u"Attempted to reset invalid url")
        raise Http404()
    except Exception as e:
        logger.warn(u"Unable to reset cache for {}".format(apiurl))
        raise Http404()
示例#5
0
def reset_cached_api(request, apiurl):
    """
    This admin call gets the url of the original api that we wish to reset, backwards resolves that original function and gets its data back into cache
    :param request:
    :param apiurl:
    :return:
    """
    from undecorated import undecorated
    # from importlib import import_module
    try:
        match = resolve("/api/{}".format(apiurl))
        #mod = import_module(".".join(match.view_name.split(".")[:-1])) Dont actually need this, resolve gets us the func itself
        #func = mod.__getattribute__(match.func.func_name)

        if "django_cache" in match.func.func_dict:
            api_view = undecorated(match.func)
            redecorated_api_view = scache.django_cache(action="reset")(api_view)
            redecorated_api_view(request, *match.args, **match.kwargs)

            return HttpResponseRedirect("/api/{}".format(apiurl))
        else:
            raise Http404("API not in cache")

    except Resolver404 as re:
        logger.warn("Attempted to reset invalid url")
        raise Http404()
    except Exception as e:
        logger.warn("Unable to reset cache for {}".format(apiurl))
        raise Http404()
示例#6
0
def regenerate_link_count_api(cat1, cat2):
    print "link_count_api:, Category1: {}, Category2: {}".format(cat1, cat2)
    django_cache(action="set",
                 cache_prefix='link_count_api')(get_link_counts)(cat1=cat1,
                                                                 cat2=cat2)
示例#7
0
def regenerate_version_status_tree():
    for lang in [None, "he", "en"]:
        django_cache(action="set", cache_prefix='version_status_tree_api')(
            library.simplify_toc)(lang=lang if lang else "")
def regenerate_link_count_api(cat1, cat2):
    print "link_count_api:, Category1: {}, Category2: {}".format(cat1, cat2)
    django_cache(action="set", cache_prefix='link_count_api')(get_link_counts)(cat1=cat1, cat2=cat2)
def regenerate_version_status_tree():
    for lang in [None, "he", "en"]:
        django_cache(action="set", cache_prefix='version_status_tree_api')(library.simplify_toc)(lang=lang if lang else "")