Skip to content

Commit

Permalink
Merge pull request ckan#212 from JVickery-TBS/feature/dump-all-views
Browse files Browse the repository at this point in the history
Dump All Resource Views
  • Loading branch information
wardi authored Dec 29, 2023
2 parents 4aa7d25 + 313364c commit 963f927
Showing 1 changed file with 6 additions and 9 deletions.
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

0 comments on commit 963f927

Please sign in to comment.