Example #1
0
def fetch_and_store(url):
    try:
        (title, text) = fetch_and_clean(url)
    except Exception:
        raise Http404(url)

    doc = SearchDocument()
    doc.url = url
    doc.title = title
    doc.text = text
    doc.save()
    return doc
Example #2
0
def fetch_and_store(url):
    try:
        (title, text) = fetch_and_clean(url)
    except Exception:
        raise Http404(url)

    doc = SearchDocument()
    doc.url = url
    doc.title = title
    doc.text = text
    doc.save()
    return doc
Example #3
0
            return HttpResponseServerError(str(e))

    if not doc:
        if not text:
            return HttpResponseNotFound(str(url or uuid))
        else:
            doc = SearchDocument()
            doc.text = text
            if title:
                doc.title = title
            if url:
                doc.url = url
            ua_string = request.META.get('HTTP_USER_AGENT')
            if ua_string is not None:
                doc.user_agent = ua_string[:255]
            doc.save()


    # The actual proxying:
    response = execute_search(doc, doctype)
    if isinstance(response, HttpResponse):
        return response

    record_matches(doc, response)

    # These changes are specific to this request and should not be stored in the database.
    response['uuid'] = doc.uuid
    if (url or uuid) and 'text' not in response:
        response['text'] = doc.text
    if title and 'title' not in response:
        response['title'] = doc.title
Example #4
0
            return HttpResponseServerError(str(e))

    if not doc:
        if not text:
            return HttpResponseNotFound(str(url or uuid))
        else:
            doc = SearchDocument()
            doc.text = text
            if title:
                doc.title = title
            if url:
                doc.url = url
            ua_string = request.META.get('HTTP_USER_AGENT')
            if ua_string is not None:
                doc.user_agent = ua_string[:255]
            doc.save()

    # The actual proxying:
    response = execute_search(doc, doctype)
    if isinstance(response, HttpResponse):
        return response

    record_matches(doc, response)

    # These changes are specific to this request and should not be stored in the database.
    response['uuid'] = doc.uuid
    if (url or uuid) and 'text' not in response:
        response['text'] = doc.text
    if title and 'title' not in response:
        response['title'] = doc.title
    if uuid and doc.url: