Fixed issue where object aliases were not being included in searches.

This commit is contained in:
Kelketek 2013-12-23 13:38:40 -06:00
parent 7b5128d0a9
commit 46a7e891d1
2 changed files with 5 additions and 5 deletions

View file

@ -197,7 +197,6 @@ class ObjectManager(TypedObjectManager):
# if candidates is an empty iterable there can be no matches # if candidates is an empty iterable there can be no matches
# Exit early. # Exit early.
return [] return []
# build query objects # build query objects
candidates_id = [_GA(obj, "id") for obj in make_iter(candidates) if obj] candidates_id = [_GA(obj, "id") for obj in make_iter(candidates) if obj]
cand_restriction = candidates != None and Q(pk__in=make_iter(candidates_id)) or Q() cand_restriction = candidates != None and Q(pk__in=make_iter(candidates_id)) or Q()
@ -205,7 +204,7 @@ class ObjectManager(TypedObjectManager):
if exact: if exact:
# exact match - do direct search # exact match - do direct search
return self.filter(cand_restriction & type_restriction & (Q(db_key__iexact=ostring) | return self.filter(cand_restriction & type_restriction & (Q(db_key__iexact=ostring) |
Q(db_tags__db_key__iexact=ostring) & Q(db_tags__db_category__iexact="object_alias"))).distinct() Q(db_tags__db_key__iexact=ostring) & Q(db_tags__db_category__iexact="objectalias"))).distinct()
elif candidates: elif candidates:
# fuzzy with candidates # fuzzy with candidates
key_candidates = self.filter(cand_restriction & type_restriction) key_candidates = self.filter(cand_restriction & type_restriction)
@ -219,7 +218,8 @@ class ObjectManager(TypedObjectManager):
if index_matches: if index_matches:
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches] return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
else: else:
alias_candidates = self.filter(id__in=candidates_id, db_tags__db_category__iexact="object_alias") alias_candidates = self.filter(id__in=candidates_id, db_tags__db_category__iexact="objectalias")
print alias_candidates
alias_strings = alias_candidates.values_list("db_key", flat=True) alias_strings = alias_candidates.values_list("db_key", flat=True)
index_matches = string_partial_matching(alias_strings, ostring, ret_index=True) index_matches = string_partial_matching(alias_strings, ostring, ret_index=True)
if index_matches: if index_matches:

View file

@ -141,8 +141,8 @@ class ObjectDB(TypedObject):
_GA(self, "cmdset").update(init_mode=True) _GA(self, "cmdset").update(init_mode=True)
_SA(self, "scripts", ScriptHandler(self)) _SA(self, "scripts", ScriptHandler(self))
_SA(self, "attributes", AttributeHandler(self)) _SA(self, "attributes", AttributeHandler(self))
_SA(self, "tags", TagHandler(self, category_prefix="object_")) _SA(self, "tags", TagHandler(self, category_prefix="object"))
_SA(self, "aliases", AliasHandler(self, category_prefix="object_")) _SA(self, "aliases", AliasHandler(self, category_prefix="object"))
_SA(self, "nicks", NickHandler(self)) _SA(self, "nicks", NickHandler(self))
# make sure to sync the contents cache when initializing # make sure to sync the contents cache when initializing
#_GA(self, "contents_update")() #_GA(self, "contents_update")()