ckan / ideas

[DEPRECATED] Use the main CKAN repo Discussions instead:
https://github.com/ckan/ckan/discussions
40 stars 2 forks source link

Automatic datastore resource aliases #264

Open jqnatividad opened 4 years ago

jqnatividad commented 4 years ago

A CKAN configuration option to set resource alias automatically:

ckan.datastore.auto_alias = True/False
ckan.datastore.auto_alias_template = {package-id}-{resource-title}

where ckan.datastore.auto_alias_template is a python format() string, with predefined placeholder values {package-id}, {resource-title}, {organization-id}, etc, and a default setting of "{package-id}-{resource-title}" or "{organization-id}-{package-id}-{resource-title}"

when datastore_create is called and auto_alias is True, it will automatically create the alias using the template. The existing behavior of existing aliases being overwritten is actually desirable, as this allows Datastore API users to use the latest resource using the alias without depending on the resource-id hash and make their code more readable.

This ability is quite useful with scheming as well, especially if you're using the datastore_choices_helper, as your scheming configuration will not have to hardcode a resource-id, and will automatically use the latest version of the resource using the alias.

cc @ckan/core