Made aliases work with the new handler. The location.contents updated is not working yet - this causes locational information to not be available until objects and manually initialized (e.g. by calling examine #dbref)

This commit is contained in:
Griatch 2013-07-12 20:21:52 +02:00
parent 45706f598a
commit 6bc16e46cc
13 changed files with 236 additions and 76 deletions

View file

@ -198,7 +198,8 @@ class ObjectManager(TypedObjectManager):
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
if exact:
# exact match - do direct search
return self.filter(cand_restriction & type_restriction & (Q(db_key__iexact=ostring) | Q(alias__db_key__iexact=ostring))).distinct()
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()
elif candidates:
# fuzzy with candidates
key_candidates = self.filter(cand_restriction & type_restriction)
@ -212,7 +213,7 @@ class ObjectManager(TypedObjectManager):
if index_matches:
return [obj for ind, obj in enumerate(key_candidates) if ind in index_matches]
else:
alias_candidates = self.model.alias_set.related.model.objects.filter(db_obj__pk__in=candidates_id)
alias_candidates = self.filter(id__in=candidates_id, db_tags__db_category__iexact="object_alias")
alias_strings = alias_candidates.values_list("db_key", flat=True)
index_matches = string_partial_matching(alias_strings, ostring, ret_index=True)
if index_matches:

View file

@ -140,9 +140,9 @@ class ObjectDB(TypedObject):
_SA(self, "cmdset", CmdSetHandler(self))
_GA(self, "cmdset").update(init_mode=True)
_SA(self, "scripts", ScriptHandler(self))
_SA(self, "tags", TagHandler(self, "object"))
_SA(self, "aliases", AliasHandler(self, "object"))
_SA(self, "nicks", NickHandler(self, "object"))
_SA(self, "tags", TagHandler(self, category_prefix="object_"))
_SA(self, "aliases", AliasHandler(self, category_prefix="object_"))
_SA(self, "nicks", NickHandler(self, category_prefix="object_"))
# Wrapper properties to easily set database fields. These are
# @property decorators that allows to access these fields using
@ -569,8 +569,8 @@ class ObjectDB(TypedObject):
pnicks = self.nicks.get(category="player_nick_%s" % nicktype)
nicks = nicks + pnicks
for nick in nicks:
if searchdata == nick.db_nick:
searchdata = nick.db_real
if searchdata == nick.db_key:
searchdata = nick.db_data
break
candidates=None