From 8958c776c071e912a67149494756dc80740f7090 Mon Sep 17 00:00:00 2001 From: Michael Polidori Date: Sun, 15 Aug 2021 15:22:41 -0400 Subject: [PATCH] Fix recursive error from editor using datapusher (#486) --- ckanext/querytool/actions.py | 30 ++++++++++++++++-------------- ckanext/querytool/helpers.py | 2 +- ckanext/querytool/plugin.py | 7 ++++--- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/ckanext/querytool/actions.py b/ckanext/querytool/actions.py index 154ae46e..f4c395bd 100644 --- a/ckanext/querytool/actions.py +++ b/ckanext/querytool/actions.py @@ -6,27 +6,29 @@ log = logging.getLogger(__name__) +# Test disabling lru_cache + # Module API -def resource_delete(context, data_dict): - _clear_get_resource_data_cache() - return delete_core.resource_delete(context, data_dict) +# def resource_delete(context, data_dict): +# _clear_get_resource_data_cache() +# return delete_core.resource_delete(context, data_dict) -def resource_patch(context, data_dict): - _clear_get_resource_data_cache() - return patch_core.resource_patch(context, data_dict) +# def resource_patch(context, data_dict): +# _clear_get_resource_data_cache() +# return patch_core.resource_patch(context, data_dict) -def resource_update(context, data_dict): - _clear_get_resource_data_cache() - return update_core.resource_update(context, data_dict) +# def resource_update(context, data_dict): +# _clear_get_resource_data_cache() +# return update_core.resource_update(context, data_dict) # Internal -def _clear_get_resource_data_cache(): - log.debug('Cache statistics for `helpers.get_resource_data`:') - log.debug(helpers.get_resource_data.cache_info()) - helpers.get_resource_data.cache_clear() - log.debug('Cache for `helpers.get_resource_data` has been reset') +# def _clear_get_resource_data_cache(): +# log.debug('Cache statistics for `helpers.get_resource_data`:') +# log.debug(helpers.get_resource_data.cache_info()) +# helpers.get_resource_data.cache_clear() +# log.debug('Cache for `helpers.get_resource_data` has been reset') diff --git a/ckanext/querytool/helpers.py b/ckanext/querytool/helpers.py index c0dec15b..5c1ef185 100644 --- a/ckanext/querytool/helpers.py +++ b/ckanext/querytool/helpers.py @@ -501,7 +501,7 @@ def get_map_data(geojson_url, map_key_field, data_key_field, return map_data -@functools32.lru_cache(maxsize=128) +# @functools32.lru_cache(maxsize=128) def get_resource_data(sql_string): context = {} diff --git a/ckanext/querytool/plugin.py b/ckanext/querytool/plugin.py index 713bf316..6b4b5f76 100644 --- a/ckanext/querytool/plugin.py +++ b/ckanext/querytool/plugin.py @@ -236,11 +236,12 @@ def after_map(self, map): # IActions def get_actions(self): + # Disable lru_cache module_root = 'ckanext.querytool.logic.action' action_functions = h._get_functions(module_root) - action_functions['resource_delete'] = actions.resource_delete - action_functions['resource_patch'] = actions.resource_patch - action_functions['resource_update'] = actions.resource_update + # action_functions['resource_delete'] = actions.resource_delete + # action_functions['resource_patch'] = actions.resource_patch + # action_functions['resource_update'] = actions.resource_update return action_functions # IConfigurable