Skip to content

Commit

Permalink
just use unicode in _parse_sort_clause
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi authored and amercader committed Sep 2, 2015
1 parent f9b3942 commit e17f178
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions ckanext/datastore/plugin.py
@@ -1,6 +1,5 @@
import sys
import logging
import shlex
import re

import pylons
Expand Down Expand Up @@ -352,16 +351,14 @@ def datastore_validate(self, context, data_dict, fields_types):
return data_dict

def _parse_sort_clause(self, clause, fields_types):
clause = ' '.join(shlex.split(clause.encode('utf-8')))
clause_match = re.match('^(.+?)( +(asc|desc) *)?$', clause, re.I)
clause_match = re.match(u'^(.+?)( +(asc|desc) *)?$', clause, re.I)

if not clause_match:
return False

field = clause_match.group(1)
sort = (clause_match.group(3) or 'asc').lower()
sort = (clause_match.group(3) or u'asc').lower()

field, sort = unicode(field, 'utf-8'), unicode(sort, 'utf-8')
if field not in fields_types:
return False

Expand Down

0 comments on commit e17f178

Please sign in to comment.