From 520059177f4d28a5618cfd1c1ae6bedbafce8f3b Mon Sep 17 00:00:00 2001 From: Josh Humphries Date: Thu, 12 Sep 2024 16:29:01 +0100 Subject: [PATCH] feat: compatibility fixes for vds vNext BREAKING CHANGE: compatibility fixes for vds vNext --- ckanext/iiif/builders/manifest.py | 2 +- ckanext/iiif/plugin.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ckanext/iiif/builders/manifest.py b/ckanext/iiif/builders/manifest.py index d4347d4..7fd667c 100644 --- a/ckanext/iiif/builders/manifest.py +++ b/ckanext/iiif/builders/manifest.py @@ -50,7 +50,7 @@ def match_and_build(self, identifier: str) -> Optional[dict]: raise IIIFBuildError(identifier, f'Resource {resource_id} not found') try: - result = toolkit.get_action('record_show')( + result = toolkit.get_action("vds_data_get")( {}, {'resource_id': resource_id, 'record_id': record_id} ) # we're only going to use the data part diff --git a/ckanext/iiif/plugin.py b/ckanext/iiif/plugin.py index 28d250d..317cb69 100644 --- a/ckanext/iiif/plugin.py +++ b/ckanext/iiif/plugin.py @@ -54,22 +54,20 @@ def get_blueprint(self): """ return routes.blueprints - def datastore_multisearch_modify_response(self, response): + def vds_after_multi_query(self, response, result): """ IVersionedDatastore hook. Only used if ckanext-versioned-datastore is installed. """ resource_cache = {} - resource_show = toolkit.get_action('resource_show') + resource_show = toolkit.get_action("resource_show") - for record in response['records']: - resource_id = record['resource'] + for record in result["records"]: + resource_id = record["resource"] if resource_id not in resource_cache: - resource_cache[resource_id] = resource_show({}, {'id': resource_id}) + resource_cache[resource_id] = resource_show({}, {"id": resource_id}) with suppress(Exception): - record['iiif'] = RecordManifestBuilder.build_record_manifest( - resource_cache[resource_id], record['data'] + record["iiif"] = RecordManifestBuilder.build_record_manifest( + resource_cache[resource_id], record["data"] ) - - return response