Skip to content

Commit

Permalink
satisfy lint
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Sep 3, 2012
1 parent 1cd3243 commit 6250079
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions ckanext/datastore/db.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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')

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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
Expand Down Expand Up @@ -553,7 +557,7 @@ def delete(context, data_dict):

trans.commit()
return data_dict
except Exception, e:
except Exception:
trans.rollback()
raise
finally:
Expand Down
4 changes: 2 additions & 2 deletions ckanext/datastore/logic/action.py
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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):
Expand Down

0 comments on commit 6250079

Please sign in to comment.