mirror of
https://github.com/evennia/evennia.git
synced 2026-04-04 15:07:16 +02:00
Debugged and added @cpattr and @mvattr. Added unittest cases for all default commands for which they are suitable. Many small bug fixes as part of that.
This commit is contained in:
parent
7b43c4a608
commit
6f0d21802b
11 changed files with 328 additions and 155 deletions
|
|
@ -6,6 +6,7 @@ from django.contrib.auth.models import User
|
|||
from django.db.models.fields import exceptions
|
||||
from src.typeclasses.managers import TypedObjectManager
|
||||
from src.typeclasses.managers import returns_typeclass, returns_typeclass_list
|
||||
from src.utils import utils
|
||||
|
||||
# Try to use a custom way to parse id-tagged multimatches.
|
||||
IDPARSER_PATH = getattr(settings, 'ALTERNATE_OBJECT_SEARCH_MULTIMATCH_PARSER', 'src.objects.object_search_funcs')
|
||||
|
|
@ -60,7 +61,7 @@ class ObjectManager(TypedObjectManager):
|
|||
the search criterion (e.g. in local_and_global_search).
|
||||
search_string: (string) The name or dbref to search for.
|
||||
"""
|
||||
search_string = str(search_string).lstrip('*')
|
||||
search_string = utils.to_unicode(search_string).lstrip('*')
|
||||
dbref = self.dbref(search_string)
|
||||
if not dbref:
|
||||
# not a dbref. Search by name.
|
||||
|
|
@ -99,7 +100,7 @@ class ObjectManager(TypedObjectManager):
|
|||
if exact:
|
||||
return [attr.obj for attr in attrs if attribute_value == attr.value]
|
||||
else:
|
||||
return [attr.obj for attr in attrs if str(attribute_value) in str(attr.value)]
|
||||
return [attr.obj for attr in attrs if utils.to_unicode(attribute_value) in str(attr.value)]
|
||||
|
||||
@returns_typeclass_list
|
||||
def get_objs_with_db_property(self, property_name, location=None):
|
||||
|
|
@ -144,10 +145,12 @@ class ObjectManager(TypedObjectManager):
|
|||
lstring_key = ", db_location=location"
|
||||
lstring_alias = ", db_obj__db_location=location"
|
||||
if exact:
|
||||
estring = "iexact"
|
||||
matches = eval("self.filter(db_key__%s=ostring%s)" % (estring, lstring_key))
|
||||
estring = "__iexact"
|
||||
else:
|
||||
estring = "__istartswith"
|
||||
matches = eval("self.filter(db_key%s=ostring%s)" % (estring, lstring_key))
|
||||
if not matches:
|
||||
alias_matches = eval("self.model.alias_set.related.model.objects.filter(db_key__%s=ostring%s)" % (estring, lstring_alias))
|
||||
alias_matches = eval("self.model.alias_set.related.model.objects.filter(db_key%s=ostring%s)" % (estring, lstring_alias))
|
||||
matches = [alias.db_obj for alias in alias_matches]
|
||||
return matches
|
||||
|
||||
|
|
@ -205,7 +208,7 @@ class ObjectManager(TypedObjectManager):
|
|||
|
||||
# Test if we are looking for a player object
|
||||
|
||||
if str(ostring).startswith("*"):
|
||||
if utils.to_unicode(ostring).startswith("*"):
|
||||
# Player search - try to find obj by its player's name
|
||||
player_match = self.get_object_with_player(ostring)
|
||||
if player_match is not None:
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from src.server.models import ServerConfig
|
|||
from src.commands.cmdsethandler import CmdSetHandler
|
||||
from src.scripts.scripthandler import ScriptHandler
|
||||
from src.utils import logger
|
||||
from src.utils.utils import is_iter
|
||||
from src.utils.utils import is_iter, to_unicode
|
||||
|
||||
FULL_PERSISTENCE = settings.FULL_PERSISTENCE
|
||||
|
||||
|
|
@ -151,6 +151,9 @@ class NickHandler(object):
|
|||
return nick
|
||||
else:
|
||||
return Nick.objects.filter(db_obj=self.obj)
|
||||
def has(self, nick, nick_type="inputline"):
|
||||
"Returns true/false if this nick is defined or not"
|
||||
return Nick.objects.filter(db_obj=self.obj, db_nick__iexact=nick, db_type__iexact=nick_type).count()
|
||||
|
||||
#------------------------------------------------------------
|
||||
#
|
||||
|
|
@ -579,6 +582,10 @@ class ObjectDB(TypedObject):
|
|||
raw_string - raw command input coming from the command line.
|
||||
"""
|
||||
# nick replacement - we require full-word matching.
|
||||
|
||||
# do text encoding conversion
|
||||
raw_string = to_unicode(raw_string)
|
||||
|
||||
raw_list = raw_string.split(None)
|
||||
raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]]
|
||||
for nick in Nick.objects.filter(db_obj=self, db_type__in=("inputline","channel")):
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ class Object(TypeClass):
|
|||
string = "{c%s{n" % self.name
|
||||
desc = self.attr("desc")
|
||||
if desc:
|
||||
string += ":\n %s" % desc
|
||||
string += "\n %s" % desc
|
||||
exits = []
|
||||
users = []
|
||||
things = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue