Fixed a logical error in obj.manager causing it to fail to find arbitrary db_>fieldname>. Resolves Issue 373.
This commit is contained in:
parent
bda5d88c24
commit
efdb954491
4 changed files with 13 additions and 7 deletions
|
|
@ -109,7 +109,7 @@ class CmdOOCLook(MuxPlayerCommand):
|
||||||
# character is already puppeted
|
# character is already puppeted
|
||||||
sess = player.get_session(csessid)
|
sess = player.get_session(csessid)
|
||||||
sid = sess in sessions and sessions.index(sess) + 1
|
sid = sess in sessions and sessions.index(sess) + 1
|
||||||
if sess:
|
if sess and sid:
|
||||||
string += "\n - {G%s{n [%s] (played by you in session %i)" % (char.key, ", ".join(char.permissions), sid)
|
string += "\n - {G%s{n [%s] (played by you in session %i)" % (char.key, ", ".join(char.permissions), sid)
|
||||||
else:
|
else:
|
||||||
string += "\n - {R%s{n [%s] (played by someone else)" % (char.key, ", ".join(char.permissions))
|
string += "\n - {R%s{n [%s] (played by someone else)" % (char.key, ", ".join(char.permissions))
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,9 @@ class ObjectManager(TypedObjectManager):
|
||||||
"""
|
"""
|
||||||
property_name = "db_%s" % property_name.lstrip('db_')
|
property_name = "db_%s" % property_name.lstrip('db_')
|
||||||
cand_restriction = candidates and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
|
cand_restriction = candidates and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
|
||||||
|
querykwargs = {property_name:None}
|
||||||
try:
|
try:
|
||||||
return list(self.filter(cand_restriction).exclude(Q(property_name=None)))
|
return list(self.filter(cand_restriction).exclude(Q(**querykwargs)))
|
||||||
except exceptions.FieldError:
|
except exceptions.FieldError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
@ -169,10 +170,11 @@ class ObjectManager(TypedObjectManager):
|
||||||
property_value = to_unicode(property_value)
|
property_value = to_unicode(property_value)
|
||||||
if isinstance(property_name, basestring):
|
if isinstance(property_name, basestring):
|
||||||
property_name = "db_%s" % property_name.lstrip('db_')
|
property_name = "db_%s" % property_name.lstrip('db_')
|
||||||
|
querykwargs = {property_name:property_value}
|
||||||
cand_restriction = candidates and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
|
cand_restriction = candidates and Q(pk__in=[_GA(obj, "id") for obj in make_iter(candidates) if obj]) or Q()
|
||||||
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
|
type_restriction = typeclasses and Q(db_typeclass_path__in=make_iter(typeclasses)) or Q()
|
||||||
try:
|
try:
|
||||||
return list(self.filter(cand_restriction & type_restriction & Q(property_name=property_value)))
|
return list(self.filter(cand_restriction & type_restriction & Q(**querykwargs)))
|
||||||
except exceptions.FieldError:
|
except exceptions.FieldError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
@ -310,7 +312,8 @@ class ObjectManager(TypedObjectManager):
|
||||||
# no matches found - check if we are dealing with N-keyword query - if so, strip it.
|
# no matches found - check if we are dealing with N-keyword query - if so, strip it.
|
||||||
match_number, searchdata = _AT_MULTIMATCH_INPUT(searchdata)
|
match_number, searchdata = _AT_MULTIMATCH_INPUT(searchdata)
|
||||||
# run search again, with the exactness set by call
|
# run search again, with the exactness set by call
|
||||||
matches = _searcher(searchdata, candidates, typeclass, exact=exact)
|
if match_number != None or not exact:
|
||||||
|
matches = _searcher(searchdata, candidates, typeclass, exact=exact)
|
||||||
|
|
||||||
# deal with result
|
# deal with result
|
||||||
if len(matches) > 1 and match_number != None:
|
if len(matches) > 1 and match_number != None:
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,10 @@ class ObjectDB(TypedObject):
|
||||||
be a list of typeclasses for a broader search.
|
be a list of typeclasses for a broader search.
|
||||||
location (Object): Specify a location to search, if different from the self's given location
|
location (Object): Specify a location to search, if different from the self's given location
|
||||||
plus its contents. This can also be a list of locations.
|
plus its contents. This can also be a list of locations.
|
||||||
attribute_name (str): Use this named Attribute to match searchdata against, instead of object.key.
|
attribute_name (str): Define which property to search. If set, no key+alias search will be performed. This can be used to
|
||||||
|
search database fields (db_ will be automatically appended), and if that fails, it will try to
|
||||||
|
return objects having Attributes with this name and value equal to searchdata. A special
|
||||||
|
use is to search for "key" here if you want to do a key-search without including aliases.
|
||||||
quiet (bool) - don't display default error messages - return multiple matches as a list and
|
quiet (bool) - don't display default error messages - return multiple matches as a list and
|
||||||
no matches as None. If not set (default), will echo error messages and return None.
|
no matches as None. If not set (default), will echo error messages and return None.
|
||||||
exact (bool) - if unset (default) - prefers to match to beginning of string rather than not matching
|
exact (bool) - if unset (default) - prefers to match to beginning of string rather than not matching
|
||||||
|
|
|
||||||
|
|
@ -525,7 +525,7 @@ def create_player(name, email, password,
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
del new_character
|
del new_player
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue