diff --git a/ckanext/datastore/db.py b/ckanext/datastore/db.py index 6a31755512c..5618d2a74f9 100644 --- a/ckanext/datastore/db.py +++ b/ckanext/datastore/db.py @@ -791,7 +791,7 @@ def _insert_links(data_dict, limit, offset): def delete_data(context, data_dict): - validate_query(context, data_dict) + validate(context, data_dict) fields = _get_fields(context, data_dict) field_ids = set([field['id'] for field in fields]) @@ -812,7 +812,7 @@ def delete_data(context, data_dict): _execute_single_statement(context, sql_string, where_values) -def validate_query(context, data_dict): +def validate(context, data_dict): all_fields = _get_fields(context, data_dict) all_field_ids = _pluck('id', all_fields) all_field_ids.insert(0, '_id') @@ -825,9 +825,9 @@ def validate_query(context, data_dict): data_dict_copy['fields'] = fields for plugin in p.PluginImplementations(interfaces.IDatastore): - data_dict_copy = plugin.datastore_validate_query(context, - data_dict_copy, - all_field_ids) + data_dict_copy = plugin.datastore_validate(context, + data_dict_copy, + all_field_ids) # Remove default elements in data_dict del data_dict_copy['connection_url'] @@ -850,7 +850,7 @@ def validate_query(context, data_dict): def search_data(context, data_dict): - validate_query(context, data_dict) + validate(context, data_dict) all_fields = _get_fields(context, data_dict) all_field_ids = _pluck('id', all_fields) all_field_ids.insert(0, '_id') diff --git a/ckanext/datastore/interfaces.py b/ckanext/datastore/interfaces.py index d8df537e1c8..d605f27d80d 100644 --- a/ckanext/datastore/interfaces.py +++ b/ckanext/datastore/interfaces.py @@ -4,7 +4,7 @@ class IDatastore(interfaces.Interface): '''Allow modifying Datastore queries''' - def datastore_validate_query(self, context, data_dict, all_field_ids): + def datastore_validate(self, context, data_dict, all_field_ids): '''Validates the ``data_dict`` sent by the user This is the first method that's called. It's used to guarantee that diff --git a/ckanext/datastore/plugin.py b/ckanext/datastore/plugin.py index 5afdd13c788..ec53d3b4b96 100644 --- a/ckanext/datastore/plugin.py +++ b/ckanext/datastore/plugin.py @@ -269,7 +269,7 @@ def before_show(self, resource_dict): connection.close() return resource_dict - def datastore_validate_query(self, context, data_dict, all_field_ids): + def datastore_validate(self, context, data_dict, all_field_ids): fields = data_dict.get('fields') if fields: data_dict['fields'] = list(set(fields) - set(all_field_ids)) diff --git a/ckanext/datastore/tests/sample_datastore_plugin.py b/ckanext/datastore/tests/sample_datastore_plugin.py index dd3c1964cd3..b090b76ad92 100644 --- a/ckanext/datastore/tests/sample_datastore_plugin.py +++ b/ckanext/datastore/tests/sample_datastore_plugin.py @@ -6,7 +6,7 @@ class SampleDataStorePlugin(p.SingletonPlugin): p.implements(interfaces.IDatastore, inherit=True) - def datastore_validate_query(self, context, data_dict, all_field_ids): + def datastore_validate(self, context, data_dict, all_field_ids): valid_filters = ('age_between', 'age_not_between', 'insecure_filter') filters = data_dict.get('filters', {}) for key in filters.keys():