Removed a lot of old references to Aliases and Nicks. Still failing on @puppet.
This commit is contained in:
parent
0061f884ae
commit
c0b5c506a4
5 changed files with 85 additions and 70 deletions
|
|
@ -123,7 +123,7 @@ class CmdSetObjAlias(MuxCommand):
|
||||||
return
|
return
|
||||||
if self.rhs == None:
|
if self.rhs == None:
|
||||||
# no =, so we just list aliases on object.
|
# no =, so we just list aliases on object.
|
||||||
aliases = obj.aliases
|
aliases = obj.aliases.all()
|
||||||
if aliases:
|
if aliases:
|
||||||
caller.msg("Aliases for '%s': %s" % (obj.key, ", ".join(aliases)))
|
caller.msg("Aliases for '%s': %s" % (obj.key, ", ".join(aliases)))
|
||||||
else:
|
else:
|
||||||
|
|
@ -136,22 +136,22 @@ class CmdSetObjAlias(MuxCommand):
|
||||||
|
|
||||||
if not self.rhs:
|
if not self.rhs:
|
||||||
# we have given an empty =, so delete aliases
|
# we have given an empty =, so delete aliases
|
||||||
old_aliases = obj.aliases
|
old_aliases = obj.aliases.all()
|
||||||
if old_aliases:
|
if old_aliases:
|
||||||
caller.msg("Cleared aliases from %s: %s" % (obj.key, ", ".join(old_aliases)))
|
caller.msg("Cleared aliases from %s: %s" % (obj.key, ", ".join(old_aliases)))
|
||||||
del obj.dbobj.aliases
|
obj.dbobj.db_aliases.clear()
|
||||||
else:
|
else:
|
||||||
caller.msg("No aliases to clear.")
|
caller.msg("No aliases to clear.")
|
||||||
return
|
return
|
||||||
|
|
||||||
# merge the old and new aliases (if any)
|
# merge the old and new aliases (if any)
|
||||||
old_aliases = obj.aliases
|
old_aliases = obj.aliases.all()
|
||||||
new_aliases = [alias.strip().lower() for alias in self.rhs.split(',') if alias.strip()]
|
new_aliases = [alias.strip().lower() for alias in self.rhs.split(',') if alias.strip()]
|
||||||
# make the aliases only appear once
|
# make the aliases only appear once
|
||||||
old_aliases.extend(new_aliases)
|
old_aliases.extend(new_aliases)
|
||||||
aliases = list(set(old_aliases))
|
aliases = list(set(old_aliases))
|
||||||
# save back to object.
|
# save back to object.
|
||||||
obj.aliases = aliases
|
obj.aliases.add(aliases)
|
||||||
# we treat this as a re-caching (relevant for exits to re-build their exit commands with the correct aliases)
|
# we treat this as a re-caching (relevant for exits to re-build their exit commands with the correct aliases)
|
||||||
caller.msg("Aliases for '%s' are now set to %s." % (obj.key, ", ".join(obj.aliases)))
|
caller.msg("Aliases for '%s' are now set to %s." % (obj.key, ", ".join(obj.aliases)))
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ class CmdCopy(ObjManipCommand):
|
||||||
if not from_obj:
|
if not from_obj:
|
||||||
return
|
return
|
||||||
to_obj_name = "%s_copy" % from_obj_name
|
to_obj_name = "%s_copy" % from_obj_name
|
||||||
to_obj_aliases = ["%s_copy" % alias for alias in from_obj.aliases]
|
to_obj_aliases = ["%s_copy" % alias for alias in from_obj.aliases.all()]
|
||||||
copiedobj = ObjectDB.objects.copy_object(from_obj, new_key=to_obj_name,
|
copiedobj = ObjectDB.objects.copy_object(from_obj, new_key=to_obj_name,
|
||||||
new_aliases=to_obj_aliases)
|
new_aliases=to_obj_aliases)
|
||||||
if copiedobj:
|
if copiedobj:
|
||||||
|
|
@ -598,8 +598,8 @@ class CmdDig(ObjManipCommand):
|
||||||
aliases=room["aliases"], report_to=caller)
|
aliases=room["aliases"], report_to=caller)
|
||||||
new_room.locks.add(lockstring)
|
new_room.locks.add(lockstring)
|
||||||
alias_string = ""
|
alias_string = ""
|
||||||
if new_room.aliases:
|
if new_room.aliases.all():
|
||||||
alias_string = " (%s)" % ", ".join(new_room.aliases)
|
alias_string = " (%s)" % ", ".join(new_room.aliases.all())
|
||||||
room_string = "Created room %s(%s)%s of type %s." % (new_room, new_room.dbref, alias_string, typeclass)
|
room_string = "Created room %s(%s)%s of type %s." % (new_room, new_room.dbref, alias_string, typeclass)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -626,8 +626,8 @@ class CmdDig(ObjManipCommand):
|
||||||
aliases=to_exit["aliases"],
|
aliases=to_exit["aliases"],
|
||||||
locks=lockstring, destination=new_room, report_to=caller)
|
locks=lockstring, destination=new_room, report_to=caller)
|
||||||
alias_string = ""
|
alias_string = ""
|
||||||
if new_to_exit.aliases:
|
if new_to_exit.aliases.all():
|
||||||
alias_string = " (%s)" % ", ".join(new_to_exit.aliases)
|
alias_string = " (%s)" % ", ".join(new_to_exit.aliases.all())
|
||||||
exit_to_string = "\nCreated Exit from %s to %s: %s(%s)%s."
|
exit_to_string = "\nCreated Exit from %s to %s: %s(%s)%s."
|
||||||
exit_to_string = exit_to_string % (location.name, new_room.name, new_to_exit,
|
exit_to_string = exit_to_string % (location.name, new_room.name, new_to_exit,
|
||||||
new_to_exit.dbref, alias_string)
|
new_to_exit.dbref, alias_string)
|
||||||
|
|
@ -651,8 +651,8 @@ class CmdDig(ObjManipCommand):
|
||||||
new_room, aliases=back_exit["aliases"],
|
new_room, aliases=back_exit["aliases"],
|
||||||
locks=lockstring, destination=location, report_to=caller)
|
locks=lockstring, destination=location, report_to=caller)
|
||||||
alias_string = ""
|
alias_string = ""
|
||||||
if new_back_exit.aliases:
|
if new_back_exit.aliases.all():
|
||||||
alias_string = " (%s)" % ", ".join(new_back_exit.aliases)
|
alias_string = " (%s)" % ", ".join(new_back_exit.aliases.all())
|
||||||
exit_back_string = "\nCreated Exit back from %s to %s: %s(%s)%s."
|
exit_back_string = "\nCreated Exit back from %s to %s: %s(%s)%s."
|
||||||
exit_back_string = exit_back_string % (new_room.name, location.name,
|
exit_back_string = exit_back_string % (new_room.name, location.name,
|
||||||
new_back_exit, new_back_exit.dbref, alias_string)
|
new_back_exit, new_back_exit.dbref, alias_string)
|
||||||
|
|
@ -979,7 +979,7 @@ class CmdName(ObjManipCommand):
|
||||||
obj.name = newname
|
obj.name = newname
|
||||||
astring = ""
|
astring = ""
|
||||||
if aliases:
|
if aliases:
|
||||||
obj.aliases = aliases
|
[obj.aliases.add(alias) for alias in aliases]
|
||||||
astring = " (%s)" % (", ".join(aliases))
|
astring = " (%s)" % (", ".join(aliases))
|
||||||
# fix for exits - we need their exit-command to change name too
|
# fix for exits - we need their exit-command to change name too
|
||||||
if obj.destination:
|
if obj.destination:
|
||||||
|
|
@ -1037,7 +1037,7 @@ class CmdOpen(ObjManipCommand):
|
||||||
if old_destination.id != destination.id:
|
if old_destination.id != destination.id:
|
||||||
# reroute the old exit.
|
# reroute the old exit.
|
||||||
exit_obj.destination = destination
|
exit_obj.destination = destination
|
||||||
exit_obj.aliases = exit_aliases
|
[exit_obj.aliases.add(alias) for alias in exit_aliases]
|
||||||
string += " Rerouted its old destination '%s' to '%s' and changed aliases." % \
|
string += " Rerouted its old destination '%s' to '%s' and changed aliases." % \
|
||||||
(old_destination.name, destination.name)
|
(old_destination.name, destination.name)
|
||||||
else:
|
else:
|
||||||
|
|
@ -1568,8 +1568,8 @@ class CmdExamine(ObjManipCommand):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
string = "\n{wName/key{n: {c%s{n (%s)" % (obj.name, obj.dbref)
|
string = "\n{wName/key{n: {c%s{n (%s)" % (obj.name, obj.dbref)
|
||||||
if hasattr(obj, "aliases") and obj.aliases:
|
if hasattr(obj, "aliases") and obj.aliases.all():
|
||||||
string += "\n{wAliases{n: %s" % (", ".join(utils.make_iter(obj.aliases)))
|
string += "\n{wAliases{n: %s" % (", ".join(utils.make_iter(obj.aliases.all())))
|
||||||
if hasattr(obj, "sessid") and obj.sessid:
|
if hasattr(obj, "sessid") and obj.sessid:
|
||||||
string += "\n{wsession{n: %s" % obj.sessid
|
string += "\n{wsession{n: %s" % obj.sessid
|
||||||
elif hasattr(obj, "sessions") and obj.sessions:
|
elif hasattr(obj, "sessions") and obj.sessions:
|
||||||
|
|
@ -1785,7 +1785,7 @@ class CmdFind(MuxCommand):
|
||||||
nresults = results.count()
|
nresults = results.count()
|
||||||
if not nresults:
|
if not nresults:
|
||||||
# no matches on the keys. Try aliases instead.
|
# no matches on the keys. Try aliases instead.
|
||||||
results = results = ObjectDB.alias_set.related.model.objects.filter(db_key=searchstring)
|
results = ObjectDB.db_aliases.filter(db_key=searchstring)
|
||||||
if "room" in switches:
|
if "room" in switches:
|
||||||
results = results.filter(db_obj__db_location__isnull=True)
|
results = results.filter(db_obj__db_location__isnull=True)
|
||||||
if "exit" in switches:
|
if "exit" in switches:
|
||||||
|
|
|
||||||
|
|
@ -420,7 +420,7 @@ def holds(accessing_obj, accessed_obj, *args, **kwargs):
|
||||||
return True
|
return True
|
||||||
objid = objid.lower()
|
objid = objid.lower()
|
||||||
return any((True for obj in contents
|
return any((True for obj in contents
|
||||||
if obj.key.lower() == objid or objid in [al.lower() for al in obj.aliases]))
|
if obj.key.lower() == objid or objid in [al.lower() for al in obj.aliases.all()]))
|
||||||
if not args:
|
if not args:
|
||||||
# holds() - check if accessed_obj or accessed_obj.obj is held by accessing_obj
|
# holds() - check if accessed_obj or accessed_obj.obj is held by accessing_obj
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
|
|
@ -910,7 +910,7 @@ class Exit(Object):
|
||||||
|
|
||||||
# create an exit command.
|
# create an exit command.
|
||||||
cmd = ExitCommand(key=exidbobj.db_key.strip().lower(),
|
cmd = ExitCommand(key=exidbobj.db_key.strip().lower(),
|
||||||
aliases=exidbobj.aliases,
|
aliases=exidbobj.aliases.all(),
|
||||||
locks=str(exidbobj.locks),
|
locks=str(exidbobj.locks),
|
||||||
auto_help=False,
|
auto_help=False,
|
||||||
destination=exidbobj.db_destination,
|
destination=exidbobj.db_destination,
|
||||||
|
|
|
||||||
|
|
@ -365,27 +365,29 @@ class TagHandler(object):
|
||||||
|
|
||||||
def add(self, tag, category=None, data=None):
|
def add(self, tag, category=None, data=None):
|
||||||
"Add a new tag to the handler"
|
"Add a new tag to the handler"
|
||||||
tag = tag.strip().lower() if tag!=None else None
|
for tag in make_iter(tag):
|
||||||
category = "%s%s" % (self.prefix, category.strip.lower()) if category!=None else None
|
tag = tag.strip().lower() if tag!=None else None
|
||||||
data = str(data) if data!=None else None
|
category = "%s%s" % (self.prefix, category.strip.lower()) if category!=None else None
|
||||||
# this will only create tag if no matches existed beforehand (it will overload
|
data = str(data) if data!=None else None
|
||||||
# data on an existing tag since that is not considered part of making the tag unique)
|
# this will only create tag if no matches existed beforehand (it will overload
|
||||||
tagobj = Tag.objects.create_tag(key=tag, category=category, data=data)
|
# data on an existing tag since that is not considered part of making the tag unique)
|
||||||
self.obj.db_tags.add(tagobj)
|
tagobj = Tag.objects.create_tag(key=tag, category=category, data=data)
|
||||||
|
self.obj.db_tags.add(tagobj)
|
||||||
|
|
||||||
def remove(self, tag, category=None):
|
def remove(self, tag, category=None):
|
||||||
"Remove a tag from the handler"
|
"Remove a tag from the handler"
|
||||||
tag = tag.strip().lower() if tag!=None else None
|
for tag in make_iter(tag):
|
||||||
category = "%s%s" % (self.prefix, category.strip.lower()) if category!=None else None
|
tag = tag.strip().lower() if tag!=None else None
|
||||||
#TODO This does not delete the tag object itself. Maybe it should do that when no
|
category = "%s%s" % (self.prefix, category.strip.lower()) if category!=None else None
|
||||||
# objects reference the tag anymore?
|
#TODO This does not delete the tag object itself. Maybe it should do that when no
|
||||||
tagobj = self.obj.db_tags.filter(db_key=tag, db_category=category)
|
# objects reference the tag anymore?
|
||||||
if tagobj:
|
tagobj = self.obj.db_tags.filter(db_key=tag, db_category=category)
|
||||||
self.obj.remove(tagobj[0])
|
if tagobj:
|
||||||
|
self.obj.remove(tagobj[0])
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
"Get all tags in this handler"
|
"Get all tags in this handler"
|
||||||
return self.obj.db_tags.all().get_values("db_key")
|
return self.obj.db_tags.all().values_list("db_key")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ",".join(self.all())
|
return ",".join(self.all())
|
||||||
|
|
@ -412,21 +414,23 @@ class AliasHandler(object):
|
||||||
"Add a new nick to the handler"
|
"Add a new nick to the handler"
|
||||||
if not alias or not alias.strip():
|
if not alias or not alias.strip():
|
||||||
return
|
return
|
||||||
alias = alias.strip()
|
for al in make_iter(alias):
|
||||||
# create a unique tag only if it didn't already exist
|
al = al.strip()
|
||||||
aliasobj = Tag.objects.create_tag(key=alias, category=self.category)
|
# create a unique tag only if it didn't already exist
|
||||||
self.obj.db_tags.add(aliasobj)
|
aliasobj = Tag.objects.create_tag(key=al, category=self.category)
|
||||||
|
self.obj.db_tags.add(aliasobj)
|
||||||
|
|
||||||
def remove(self, alias):
|
def remove(self, alias):
|
||||||
"Remove alias from handler."
|
"Remove alias from handler."
|
||||||
aliasobj = Tag.objects.filter(db_key__iexact=alias.strip(), category=self.category).count()
|
for alias in make_iter(alias):
|
||||||
#TODO note that this doesn't delete the tag itself. We might want to do this when no object
|
aliasobj = Tag.objects.filter(db_key__iexact=alias.strip(), category=self.category).count()
|
||||||
# uses it anymore ...
|
#TODO note that this doesn't delete the tag itself. We might want to do this when no object
|
||||||
self.obj.db_tags.remove(aliasobj)
|
# uses it anymore ...
|
||||||
|
self.obj.db_tags.remove(aliasobj)
|
||||||
|
|
||||||
def all(self):
|
def all(self):
|
||||||
"Get all aliases in this handler"
|
"Get all aliases in this handler"
|
||||||
return self.obj.db_tags.filter(db_category=self.category).get_values("db_key")
|
return list(self.obj.db_tags.filter(db_category=self.category).values_list("db_key"))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return ",".join(self.all())
|
return ",".join(self.all())
|
||||||
|
|
@ -466,27 +470,29 @@ class NickHandler(object):
|
||||||
"""
|
"""
|
||||||
if not nick or not nick.strip():
|
if not nick or not nick.strip():
|
||||||
return
|
return
|
||||||
nick = nick.strip()
|
for nick in make_iter(nick):
|
||||||
real = realname
|
nick = nick.strip()
|
||||||
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
real = realname
|
||||||
query = self.obj.db_liteattributes.filter(db_key__iexact=nick, db_category__iexact=nick_type)
|
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
||||||
if query.count():
|
query = self.obj.db_liteattributes.filter(db_key__iexact=nick, db_category__iexact=nick_type)
|
||||||
old_nick = query[0]
|
if query.count():
|
||||||
old_nick.db_data = real
|
old_nick = query[0]
|
||||||
old_nick.save()
|
old_nick.db_data = real
|
||||||
else:
|
old_nick.save()
|
||||||
new_nick = LiteAttribute(db_key=nick, db_category=nick_type, db_data=real)
|
else:
|
||||||
new_nick.save()
|
new_nick = LiteAttribute(db_key=nick, db_category=nick_type, db_data=real)
|
||||||
self.obj.db_liteattributes.add(new_nick)
|
new_nick.save()
|
||||||
|
self.obj.db_liteattributes.add(new_nick)
|
||||||
|
|
||||||
def remove(self, nick, nick_type="inputline"):
|
def remove(self, nick, nick_type="inputline"):
|
||||||
"Removes a previously stored nick"
|
"Removes a previously stored nick"
|
||||||
nick = nick.strip()
|
for nick in make_iter(nick):
|
||||||
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
nick = nick.strip()
|
||||||
query = self.obj.liteattributes.filter(db_key__iexact=nick, db_category__iexact=nick_type)
|
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
||||||
if query.count():
|
query = self.obj.liteattributes.filter(db_key__iexact=nick, db_category__iexact=nick_type)
|
||||||
# remove the found nick(s)
|
if query.count():
|
||||||
query.delete()
|
# remove the found nick(s)
|
||||||
|
query.delete()
|
||||||
|
|
||||||
def delete(self, *args, **kwargs):
|
def delete(self, *args, **kwargs):
|
||||||
"alias wrapper"
|
"alias wrapper"
|
||||||
|
|
@ -500,14 +506,23 @@ class NickHandler(object):
|
||||||
If no nick is given, returns a list of all matching nick
|
If no nick is given, returns a list of all matching nick
|
||||||
objects (LiteAttributes) on the object, or the empty list.
|
objects (LiteAttributes) on the object, or the empty list.
|
||||||
"""
|
"""
|
||||||
nick = nick.strip().lower() if nick!=None else None
|
returns = []
|
||||||
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
for nick in make_iter(nick):
|
||||||
if nick:
|
nick = nick.strip().lower() if nick!=None else None
|
||||||
nicks = _GA(self.obj, "db_liteattributes").objects.filter(db_key=nick, db_category=nick_type).prefetch_related("db_data")
|
nick_type = "%s%s" % (self.prefix, nick_type.strip().lower())
|
||||||
default = default if default!=None else nick
|
if nick:
|
||||||
return nicks[0].db_data if nicks else default
|
nicks = _GA(self.obj, "db_liteattributes").objects.filter(db_key=nick, db_category=nick_type).prefetch_related("db_data")
|
||||||
else:
|
default = default if default!=None else nick
|
||||||
return list(self.obj.db_liteattributes.all())
|
return nicks[0].db_data if nicks else default
|
||||||
|
else:
|
||||||
|
returns.extend(list(self.obj.db_liteattributes.all()))
|
||||||
|
return returns
|
||||||
|
|
||||||
|
def all(self):
|
||||||
|
"Get all nicks in this handler"
|
||||||
|
return list(self.obj.db_nicks.filter(db_category=self.category).values_list("db_key"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------
|
#------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ def create_object(typeclass, key=None, location=None,
|
||||||
if locks:
|
if locks:
|
||||||
new_object.locks.add(locks)
|
new_object.locks.add(locks)
|
||||||
if aliases:
|
if aliases:
|
||||||
new_object.aliases = aliases
|
new_object.aliases.add(aliases)
|
||||||
|
|
||||||
# perform a move_to in order to display eventual messages.
|
# perform a move_to in order to display eventual messages.
|
||||||
if home:
|
if home:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue