Another 'right' fix for the multiple user category problem

This commit is contained in:
Charles Haley 2011-01-25 23:29:00 +00:00
parent 0b0662c632
commit df5766f02a
2 changed files with 6 additions and 4 deletions

View File

@ -424,6 +424,11 @@ class ResultCache(SearchQueryParser): # {{{
if self.db_prefs is None:
return res
user_cats = self.db_prefs.get('user_categories', [])
# translate the case of the location
for loc in user_cats:
if location == icu_lower(loc):
location = loc
break
if location not in user_cats:
return res
c = set(candidates)
@ -445,7 +450,7 @@ class ResultCache(SearchQueryParser): # {{{
if query and query.strip():
# get metadata key associated with the search term. Eliminates
# dealing with plurals and other aliases
location = self.field_metadata.search_term_to_field_key(location.lower().strip())
location = self.field_metadata.search_term_to_field_key(icu_lower(location.strip()))
if isinstance(location, list):
if allow_recursion:
for loc in location:

View File

@ -7,7 +7,6 @@ import copy
from calibre.utils.ordered_dict import OrderedDict
from calibre.utils.config import tweaks
from calibre.utils.icu import lower
class TagsIcons(dict):
'''
@ -485,7 +484,6 @@ class FieldMetadata(dict):
return self._tb_cats[key]['rec_index'] + 1
def add_user_category(self, label, name):
label = lower(label)
if label in self._tb_cats:
raise ValueError('Duplicate user field [%s]'%(label))
self._tb_cats[label] = {'table':None, 'column':None,
@ -525,7 +523,6 @@ class FieldMetadata(dict):
def _add_search_terms_to_map(self, key, terms):
if terms is not None:
for t in terms:
t = t.lower()
if t in self._search_term_map:
raise ValueError('Attempt to add duplicate search term "%s"'%t)
self._search_term_map[t] = key