Fixed remaining issues so the login process works.

This commit is contained in:
Griatch 2013-07-12 15:57:46 +02:00
parent c0b5c506a4
commit 45706f598a
5 changed files with 17 additions and 11 deletions

2
ev.py
View file

@ -119,7 +119,7 @@ from src.help.models import HelpEntry
from src.typeclasses.models import Attribute from src.typeclasses.models import Attribute
# players # players
from src.players.player import Player from src.players.player import Player
from src.players.models import PlayerDB, PlayerNick from src.players.models import PlayerDB
# commands # commands
from src.commands.command import Command from src.commands.command import Command

View file

@ -3,7 +3,6 @@ General Character commands usually availabe to all characters
""" """
from django.conf import settings from django.conf import settings
from src.utils import utils, prettytable from src.utils import utils, prettytable
from src.objects.models import ObjectNick as Nick
from src.commands.default.muxcommand import MuxCommand from src.commands.default.muxcommand import MuxCommand
@ -124,17 +123,17 @@ class CmdNick(MuxCommand):
caller = self.caller caller = self.caller
switches = self.switches 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: if 'list' in switches:
table = prettytable.PrettyTable(["{wNickType", "{wNickname", "{wTranslates-to"]) table = prettytable.PrettyTable(["{wNickType", "{wNickname", "{wTranslates-to"])
for nick in nicks: 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 string = "{wDefined Nicks:{n\n%s" % table
caller.msg(string) caller.msg(string)
return return
if 'clearall' in switches: if 'clearall' in switches:
nicks.delete() caller.nicks.clear()
caller.msg("Cleared all aliases.") caller.msg("Cleared all aliases.")
return return
if not self.args or not self.lhs: if not self.args or not self.lhs:

View file

@ -643,11 +643,11 @@ class ObjectDB(TypedObject):
raw_list = raw_string.split(None) 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]] raw_list = [" ".join(raw_list[:i+1]) for i in range(len(raw_list)) if raw_list[:i+1]]
# fetch the nick data efficiently # 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: 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") 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: for nick in nicks:
if nick.db_key in raw_list: if nick.db_key in raw_list:
raw_string = raw_string.replace(nick.db_key, nick.db_data, 1) raw_string = raw_string.replace(nick.db_key, nick.db_data, 1)

View file

@ -105,7 +105,7 @@ class ScriptDB(TypedObject):
verbose_name = "Script" verbose_name = "Script"
def __init__(self, *args, **kwargs): 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, "tags", TagHandler(self, "script"))
_SA(self, "aliases", AliasHandler(self, "script")) _SA(self, "aliases", AliasHandler(self, "script"))

View file

@ -384,6 +384,9 @@ class TagHandler(object):
tagobj = self.obj.db_tags.filter(db_key=tag, db_category=category) tagobj = self.obj.db_tags.filter(db_key=tag, db_category=category)
if tagobj: if tagobj:
self.obj.remove(tagobj[0]) self.obj.remove(tagobj[0])
def clear(self):
"Remove all tags from the handler"
self.obj.db_tags.clear()
def all(self): def all(self):
"Get all tags in this handler" "Get all tags in this handler"
@ -423,10 +426,13 @@ class AliasHandler(object):
def remove(self, alias): def remove(self, alias):
"Remove alias from handler." "Remove alias from handler."
for alias in make_iter(alias): 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 #TODO note that this doesn't delete the tag itself. We might want to do this when no object
# uses it anymore ... # uses it anymore ...
self.obj.db_tags.remove(aliasobj) 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): def all(self):
"Get all aliases in this handler" "Get all aliases in this handler"
@ -589,7 +595,8 @@ class TypedObject(SharedMemoryModel):
# lock handler self.locks # lock handler self.locks
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
"We must initialize the parent first - important!" "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, "dbobj", self) # this allows for self-reference
_SA(self, "locks", LockHandler(self)) _SA(self, "locks", LockHandler(self))