Ejemplo n.º 1
0
def query():
    enable_cache(vary_user=True)
    state = QueryState(request.args, request.authz)
    result = documents_query(state)
    params = next_params(request.args, result)
    log_event(request)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Ejemplo n.º 2
0
def query():
    enable_cache(vary_user=True, vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Ejemplo n.º 3
0
def query():
    enable_cache(vary_user=True,
                 vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Ejemplo n.º 4
0
def records(document_id):
    document = get_document(document_id)
    enable_cache(vary_user=True)
    state = QueryState(request.args, request.authz)
    query = records_query(document.id, state)
    result = execute_records_query(document.id, state, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('documents_api.records',
                                 document_id=document_id,
                                 **params)
    return jsonify(result)
Ejemplo n.º 5
0
def rows(document_id, table_id):
    document, tabular = get_tabular(document_id, table_id)
    query = tabular_query(document_id, table_id, request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()

    result = execute_tabular_query(query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('documents_api.rows', document_id=document_id,
                                 table_id=table_id, **params)
    return jsonify(result)
Ejemplo n.º 6
0
def rows(document_id, table_id):
    document, tabular = get_tabular(document_id, table_id)
    query = tabular_query(document_id, table_id, request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()

    result = execute_tabular_query(query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('documents_api.rows', document_id=document_id,
                                 table_id=table_id, **params)
    return jsonify(result)
Ejemplo n.º 7
0
def records(document_id):
    document = get_document(document_id)
    enable_cache(vary_user=True)
    query = records_query(document.id, request.args)
    if query is None:
        return jsonify({"status": "ok", "message": "no query"})
    query["size"] = get_limit(default=30)
    query["from"] = get_offset()
    result = execute_records_query(query)
    params = next_params(request.args, result)
    if params is not None:
        result["next"] = url_for("search_api.record", document_id=document_id, **params)
    return jsonify(result)
Ejemplo n.º 8
0
def query():
    enable_cache(vary_user=True, vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query["size"] = get_limit(default=100)
    query["from"] = get_offset()
    # import json
    # print json.dumps(query, indent=2)
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    log_event(request)
    if params is not None:
        result["next"] = url_for("search_api.query", **params)
    return jsonify(result)
Ejemplo n.º 9
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Ejemplo n.º 10
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Ejemplo n.º 11
0
def records(document_id):
    document = get_document(document_id)
    enable_cache(vary_user=True)
    query = records_query(document.id, request.args)
    if query is None:
        return jsonify({'status': 'ok', 'message': 'no query'})
    query['size'] = get_limit(default=30)
    query['from'] = get_offset()
    result = execute_records_query(query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.record',
                                 document_id=document_id,
                                 **params)
    return jsonify(result)
Ejemplo n.º 12
0
def _query(escape=False):
    '''
    everything here should be applicable both to the internal and to the
    public api
    '''
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args, escape=escape)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return result
Ejemplo n.º 13
0
def records(document_id):
    document = get_document(document_id)
    enable_cache(vary_user=True)
    query = records_query(document.id, request.args)
    if query is None:
        return jsonify({
            'status': 'ok',
            'message': 'no query'
        })
    query['size'] = get_limit(default=30)
    query['from'] = get_offset()
    result = execute_records_query(query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.record', document_id=document_id,
                                 **params)
    return jsonify(result)