Skip to content

Helpers

get_datastore_fields(resource_id) ΒΆ

Retrieve list of dataset fields Checked between requests so we can quickly reuse without searching again.

Parameters:

Name Type Description Default
resource_id

return:

required

Returns:

Type Description

list of field dicts

Source code in ckanext/gallery/lib/helpers.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def get_datastore_fields(resource_id):
    """
    Retrieve list of dataset fields Checked between requests so we can quickly reuse
    without searching again.

    :param resource_id: return:
    :returns: list of field dicts
    """
    try:
        fields = _cache[resource_id]
    except KeyError:
        data = {'resource_id': resource_id, 'limit': 0}
        fields = _cache[resource_id] = toolkit.get_action('datastore_search')({}, data)[
            'fields'
        ]
    return fields