Skip to content

Utils

get_resource_and_package(resource_id) ΒΆ

Given a resource ID, returns the resource's dict and the parent package's dict too.

Parameters:

Name Type Description Default
resource_id

the resource ID

required

Returns:

Type Description

a 2-tuple, containing the resource dict and the package dict

Source code in ckanext/query_dois/lib/utils.py
10
11
12
13
14
15
16
17
18
19
def get_resource_and_package(resource_id):
    """
    Given a resource ID, returns the resource's dict and the parent package's dict too.

    :param resource_id: the resource ID
    :returns: a 2-tuple, containing the resource dict and the package dict
    """
    resource = toolkit.get_action('resource_show')({}, {'id': resource_id})
    package = toolkit.get_action('package_show')({}, {'id': resource['package_id']})
    return resource, package