Open roll opened 5 years ago
Code like this was sometimes failing with Exception: Action function package_show did not call its auth function:
Exception: Action function package_show did not call its auth function
def some_helper(): context = {'model': model} # Get datasets datasets = [] ids = normalize_list(value) for id in ids: try: dataset = tk.get_action('package_show')(context, {'id': id}) href = tk.url_for('ckanext_showcase_read', id=dataset['name'], qualified=False) datasets.append({'text': dataset['title'], 'href': href}) except tk.ObjectNotFound: pass return datasets
Moving context definition inside the cycle solved this problem:
context
def some_helper(): # Get datasets datasets = [] ids = normalize_list(value) for id in ids: try: dataset = tk.get_action('package_show')({'model': model}, {'id': id}) href = tk.url_for('ckanext_showcase_read', id=dataset['name'], qualified=False) datasets.append({'text': dataset['title'], 'href': href}) except tk.ObjectNotFound: pass return datasets
We have more functions like this but it seems it doesn't create any problems, for now. But anyway it makes sense to double check.
Overview
Code like this was sometimes failing with
Exception: Action function package_show did not call its auth function
:Moving
context
definition inside the cycle solved this problem:We have more functions like this but it seems it doesn't create any problems, for now. But anyway it makes sense to double check.