Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dump All Resource Views #212

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions ckanapi/cli/dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def reply(error, record=None):
populate_datastore_res_fields(ckan, res)
if thing == 'datasets' and arguments['--resource-views']:
for res in obj.get('resources', []):
populate_datastore_res_views(ckan, res)
populate_res_views(ckan, res)
reply(None, obj)

def _worker_command_line(thing, arguments):
Expand Down Expand Up @@ -222,23 +222,20 @@ def b(name):
)


def populate_datastore_res_views(ckan, res):
def populate_res_views(ckan, res):
"""
update resource dict in-place with resource_view_list values
in every resource with datastore active using ckan
LocalCKAN/RemoteCKAN instance
in every resource with views using ckan LocalCKAN/RemoteCKAN instance
"""
if not res.get('datastore_active', False):
return
try:
ds = ckan.call_action('resource_view_list', {
views = ckan.call_action('resource_view_list', {
'id': res['id'],
'limit':0})
except CKANAPIError:
return
except NotFound:
return # with localckan we'll get the real CKAN exception not a CKANAPIError subclass
if not ds:
if not views:
return # return if the resource views list is empty
res['resource_views'] = ds
res['resource_views'] = views