From 6250079ca7227f19b799d78f96aca23d49e34f78 Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Mon, 3 Sep 2012 13:25:14 +0100 Subject: [PATCH] satisfy lint --- ckanext/datastore/db.py | 10 +++++++--- ckanext/datastore/logic/action.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ckanext/datastore/db.py b/ckanext/datastore/db.py index 93ba5ff7524..d968c179e4e 100644 --- a/ckanext/datastore/db.py +++ b/ckanext/datastore/db.py @@ -352,6 +352,7 @@ def _where(field_ids, data_dict): where_clause = 'where ' + where_clause return where_clause, values + def _sort(context, sort, field_ids): if not sort: @@ -415,7 +416,7 @@ def delete_data(context, data_dict): def search_data(context, data_dict): all_fields = _get_fields(context, data_dict) all_field_ids = map(lambda x: x['id'], all_fields) - all_field_ids.insert(0,'_id') + all_field_ids.insert(0, '_id') fields = data_dict.get('fields') @@ -448,6 +449,7 @@ def search_data(context, data_dict): results = context['connection'].execute(sql_string, where_values) return format_results(context, results, data_dict) + def format_results(context, results, data_dict): result_fields = [] for field in results.cursor.description: @@ -456,7 +458,7 @@ def format_results(context, results, data_dict): 'type': _get_type(context, field[1]) }) if len(result_fields) and result_fields[-1]['id'] == '_full_count': - result_fields.pop() # remove _full_count + result_fields.pop() # remove _full_count records = [] for row in results: @@ -471,9 +473,11 @@ def format_results(context, results, data_dict): data_dict['fields'] = result_fields return data_dict + def is_single_statement(sql): return not ';' in sql.strip(';') + def create(context, data_dict): ''' The first row will be used to guess types not in the fields and the @@ -553,7 +557,7 @@ def delete(context, data_dict): trans.commit() return data_dict - except Exception, e: + except Exception: trans.rollback() raise finally: diff --git a/ckanext/datastore/logic/action.py b/ckanext/datastore/logic/action.py index 96e3f3039fb..971da11bbcd 100644 --- a/ckanext/datastore/logic/action.py +++ b/ckanext/datastore/logic/action.py @@ -110,7 +110,7 @@ def datastore_search(context, data_dict): data_dict['connection_url'] = pylons.config['ckan.datastore_read_url'] res_exists = model.Resource.get(id) - + alias_exists = False if not res_exists: # assume id is an alias @@ -132,6 +132,7 @@ def datastore_search(context, data_dict): result.pop('connection_url') return result + @logic.side_effect_free def data_search_sql(context, data_dict): '''Execute SQL-Queries on the datastore. @@ -144,7 +145,6 @@ def data_search_sql(context, data_dict): :rtype: dictionary ''' - model = _get_or_bust(context, 'model') sql = _get_or_bust(data_dict, 'sql') if not db.is_single_statement(sql):