expressions)
-def _search(table, search_type, case_sensitive, values, expressions):
+def _search(table, search_type, case_sensitive, values,
+ expressions, orderBy=None):
_search_f = globals()['_search_%s' % search_type]
conditions = _search_f(table, case_sensitive, values, expressions)
- return table.select(conditions)
+ return table.select(conditions, orderBy=orderBy)
def search_authors(search_type, case_sensitive, values,
- expressions):
- return _search(Author, search_type, case_sensitive, values, expressions)
+ expressions, orderBy=None):
+ return _search(Author, search_type, case_sensitive, values,
+ expressions, orderBy)
-def search_books(search_type, case_sensitive, values):
- return _search(Book, search_type, case_sensitive, values, [])
+def search_books(search_type, case_sensitive, values, orderBy=None):
+ return _search(Book, search_type, case_sensitive, values,
+ [], orderBy)
-def search_extensions(search_type, case_sensitive, values):
- return _search(Extension, search_type, case_sensitive, values, [])
+def search_extensions(search_type, case_sensitive, values, orderBy=None):
+ return _search(Extension, search_type, case_sensitive, values,
+ [], orderBy)
-def search_genres(search_type, case_sensitive, values):
- return _search(Genre, search_type, case_sensitive, values, [])
+def search_genres(search_type, case_sensitive, values, orderBy=None):
+ return _search(Genre, search_type, case_sensitive, values,
+ [], orderBy)
-def search_languages(search_type, case_sensitive, values):
- return _search(Language, search_type, case_sensitive, values, [])
+def search_languages(search_type, case_sensitive, values, orderBy=None):
+ return _search(Language, search_type, case_sensitive, values,
+ [], orderBy)
if case_sensitive is None:
case_sensitive = _guess_case_sensitivity(values)
for author in search_authors(args.search_type, case_sensitive, values,
- expressions):
+ expressions,
+ orderBy=('surname', 'name', 'misc_name')):
names = filter(None, (author.surname, author.name, author.misc_name))
fullname = u' '.join(names)
print fullname.encode(default_encoding), \
case_sensitive = _guess_case_sensitivity(values)
else:
values = {}
- for ext in search_extensions(args.search_type, case_sensitive, values):
+ for ext in search_extensions(args.search_type, case_sensitive, values,
+ orderBy='name'):
print ext.name.encode(default_encoding), \
(u"(%s: %d)" % (_('books'), ext.count)).encode(default_encoding)
values[column] = unicode(value, default_encoding)
if case_sensitive is None:
case_sensitive = _guess_case_sensitivity(values)
- for genre in search_genres(args.search_type, case_sensitive, values):
+ for genre in search_genres(args.search_type, case_sensitive, values,
+ orderBy='name'):
names = filter(None, (genre.name, genre.title))
fullname = u' '.join(names)
print fullname.encode(default_encoding), \
case_sensitive = _guess_case_sensitivity(values)
else:
values = {}
- for lang in search_languages(args.search_type, case_sensitive, values):
+ for lang in search_languages(args.search_type, case_sensitive, values,
+ orderBy='name'):
print lang.name.encode(default_encoding), \
(u"(%s: %d)" % (_('books'), lang.count)).encode(default_encoding)