diff --git a/ev.py b/ev.py index 651842515..81e9968ea 100644 --- a/ev.py +++ b/ev.py @@ -119,7 +119,7 @@ from src.help.models import HelpEntry from src.typeclasses.models import Attribute # players from src.players.player import Player -from src.players.models import PlayerDB, PlayerNick +from src.players.models import PlayerDB # commands from src.commands.command import Command diff --git a/src/commands/default/general.py b/src/commands/default/general.py index 1c8c313d1..d843be95f 100644 --- a/src/commands/default/general.py +++ b/src/commands/default/general.py @@ -3,7 +3,6 @@ General Character commands usually availabe to all characters """ from django.conf import settings from src.utils import utils, prettytable -from src.objects.models import ObjectNick as Nick from src.commands.default.muxcommand import MuxCommand @@ -124,17 +123,17 @@ class CmdNick(MuxCommand): caller = self.caller switches = self.switches - nicks = Nick.objects.filter(db_obj=caller.dbobj).exclude(db_type="channel") + nicks = caller.nicks.get(category="channel") if 'list' in switches: table = prettytable.PrettyTable(["{wNickType", "{wNickname", "{wTranslates-to"]) for nick in nicks: - table.add_row([nick.db_type, nick.db_nick, nick.db_real]) + table.add_row([nick.db_category, nick.db_key, nick.db_data]) string = "{wDefined Nicks:{n\n%s" % table caller.msg(string) return if 'clearall' in switches: - nicks.delete() + caller.nicks.clear() caller.msg("Cleared all aliases.") return if not self.args or not self.lhs: diff --git a/src/objects/models.py b/src/objects/models.py index c7dccb785..54c378fc2 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -643,11 +643,11 @@ class ObjectDB(TypedObject): 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]] # fetch the nick data efficiently - nicks = self.db_lnattributes.filter(db_category__in=("object_nick_inputline", "object_nick_channel")).prefetch_related("db_key","db_data") + nicks = self.db_liteattributes.filter(db_category__in=("object_nick_inputline", "object_nick_channel")).prefetch_related("db_key","db_data") if self.has_player: - pnicks = self.player.db_lnattributes.filter( + pnicks = self.player.db_liteattributes.filter( db_category__in=("player_nick_inputline", "player_nick_channel")).prefetch_related("db_key","db_data") - nicks = nicks + pnicks + nicks = list(nicks) + list(pnicks) for nick in nicks: if nick.db_key in raw_list: raw_string = raw_string.replace(nick.db_key, nick.db_data, 1) diff --git a/src/scripts/models.py b/src/scripts/models.py index 9b47b3d0b..ca2d2f5ef 100644 --- a/src/scripts/models.py +++ b/src/scripts/models.py @@ -105,7 +105,7 @@ class ScriptDB(TypedObject): verbose_name = "Script" def __init__(self, *args, **kwargs): - super(ScriptDB, self).__init__(self, *args, **kwargs) + super(ScriptDB, self).__init__(*args, **kwargs) _SA(self, "tags", TagHandler(self, "script")) _SA(self, "aliases", AliasHandler(self, "script")) diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index 2995a3902..b816b2eb6 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -384,6 +384,9 @@ class TagHandler(object): tagobj = self.obj.db_tags.filter(db_key=tag, db_category=category) if tagobj: self.obj.remove(tagobj[0]) + def clear(self): + "Remove all tags from the handler" + self.obj.db_tags.clear() def all(self): "Get all tags in this handler" @@ -423,10 +426,13 @@ class AliasHandler(object): def remove(self, alias): "Remove alias from handler." for alias in make_iter(alias): - aliasobj = Tag.objects.filter(db_key__iexact=alias.strip(), category=self.category).count() + aliasobj = self.obj.filter(db_key__iexact=alias.strip(), category=self.category) #TODO note that this doesn't delete the tag itself. We might want to do this when no object # uses it anymore ... self.obj.db_tags.remove(aliasobj) + def clear(self): + "Clear all aliases from handler" + self.obj.db_tags.remove(self.obj.filter(categery=self.category)) def all(self): "Get all aliases in this handler" @@ -589,7 +595,8 @@ class TypedObject(SharedMemoryModel): # lock handler self.locks def __init__(self, *args, **kwargs): "We must initialize the parent first - important!" - SharedMemoryModel.__init__(self, *args, **kwargs) + super(SharedMemoryModel, self).__init__(*args, **kwargs) + #SharedMemoryModel.__init__(self, *args, **kwargs) _SA(self, "dbobj", self) # this allows for self-reference _SA(self, "locks", LockHandler(self))