Better checks for pk in delete command. Update how the delete method of objects avoid recursive calls. Resolves #1453.
This commit is contained in:
parent
0ba913332a
commit
a6ed6ff5ea
2 changed files with 28 additions and 36 deletions
|
|
@ -647,29 +647,32 @@ class CmdDestroy(COMMAND_DEFAULT_CLASS):
|
|||
def delobj(obj):
|
||||
# helper function for deleting a single object
|
||||
string = ""
|
||||
objname = obj.name
|
||||
if not (obj.access(caller, "control") or obj.access(caller, 'delete')):
|
||||
return "\nYou don't have permission to delete %s." % objname
|
||||
if obj.account and 'override' not in self.switches:
|
||||
return "\nObject %s is controlled by an active account. Use /override to delete anyway." % objname
|
||||
if obj.dbid == int(settings.DEFAULT_HOME.lstrip("#")):
|
||||
return "\nYou are trying to delete |c%s|n, which is set as DEFAULT_HOME. " \
|
||||
"Re-point settings.DEFAULT_HOME to another " \
|
||||
"object before continuing." % objname
|
||||
|
||||
had_exits = hasattr(obj, "exits") and obj.exits
|
||||
had_objs = hasattr(obj, "contents") and any(obj for obj in obj.contents
|
||||
if not (hasattr(obj, "exits") and obj not in obj.exits))
|
||||
# do the deletion
|
||||
okay = obj.delete()
|
||||
if not okay:
|
||||
string += "\nERROR: %s not deleted, probably because delete() returned False." % objname
|
||||
if not obj.pk:
|
||||
string = "\nObject %s was already deleted." % obj.db_key
|
||||
else:
|
||||
string += "\n%s was destroyed." % objname
|
||||
if had_exits:
|
||||
string += " Exits to and from %s were destroyed as well." % objname
|
||||
if had_objs:
|
||||
string += " Objects inside %s were moved to their homes." % objname
|
||||
objname = obj.name
|
||||
if not (obj.access(caller, "control") or obj.access(caller, 'delete')):
|
||||
return "\nYou don't have permission to delete %s." % objname
|
||||
if obj.account and 'override' not in self.switches:
|
||||
return "\nObject %s is controlled by an active account. Use /override to delete anyway." % objname
|
||||
if obj.dbid == int(settings.DEFAULT_HOME.lstrip("#")):
|
||||
return "\nYou are trying to delete |c%s|n, which is set as DEFAULT_HOME. " \
|
||||
"Re-point settings.DEFAULT_HOME to another " \
|
||||
"object before continuing." % objname
|
||||
|
||||
had_exits = hasattr(obj, "exits") and obj.exits
|
||||
had_objs = hasattr(obj, "contents") and any(obj for obj in obj.contents
|
||||
if not (hasattr(obj, "exits") and obj not in obj.exits))
|
||||
# do the deletion
|
||||
okay = obj.delete()
|
||||
if not okay:
|
||||
string += "\nERROR: %s not deleted, probably because delete() returned False." % objname
|
||||
else:
|
||||
string += "\n%s was destroyed." % objname
|
||||
if had_exits:
|
||||
string += " Exits to and from %s were destroyed as well." % objname
|
||||
if had_objs:
|
||||
string += " Objects inside %s were moved to their homes." % objname
|
||||
return string
|
||||
|
||||
objs = []
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue