Пример #1
0
def wiki(page):
    """Render a wiki page"""
    if ids.is_suspicious(request):
        abort(403, "Temporarily blocked due to suspicious activity")

    p = wc.get_page(page)
    try:
        return {'headers': p.headers, 'data': p.body, 'content-type': p.mime_type}
    except Exception as e:
        # fallback to index/aliases/levenshtein
        log.debug("Attempting to resolve aliases for %s" % page)
        original = wc.resolve_alias(page)
        if original and original != page:
            redirect("%s/%s" % (settings.wiki.base, original))
        log.debug("Attempting to find close matches for %s" % page)
        close = wc.get_close_matches_for_page(page)
        if len(close):
            redirect("%s/%s" % (settings.wiki.base, close[0]))
        ids.flag(request)
        abort(404, "Page not found")
    return result
Пример #2
0
def preload_pages(pages, prefix):
    for p in pages:
        log.warn(p)
        wc.get_page(p["page_name"])
    memcache.delete(prefix, namespace=NS_BATCH)