From 6161f58fe66ce3cbfa236625555ce54280a0dad8 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Thu, 9 Nov 2017 09:54:38 +0000 Subject: [PATCH] Make new-style facet deletion more robust When destroying a new-style Element, reuse the delete_facet method instead of deleting keys from the origin. Within the delete_facet method, make sure to delete the corresponding key from the facethash too. --- mudpy/misc.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mudpy/misc.py b/mudpy/misc.py index 7478f3f..c3e1940 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -91,8 +91,8 @@ class Element: if self.old_style: del self.origin.data[self.key] else: - for facet in self.facethash: - del self.origin.data[".".join((self.key, facet))] + for facet in dict(self.facethash): + self.remove_facet(facet) del self.universe.categories[self.category][self.subkey] del self.universe.contents[self.key] del self @@ -113,9 +113,13 @@ class Element: def remove_facet(self, facet): """Remove a facet from the element.""" - if self.has_facet(facet): - del(self.origin.data[self.key][facet]) - self.origin.modified = True + if self.old_style and self.has_facet(facet): + del self.origin.data[self.key][facet] + elif ".".join((self.key, facet)) in self.origin.data: + del self.origin.data[".".join((self.key, facet))] + if facet in self.facethash: + del self.facethash[facet] + self.origin.modified = True def ancestry(self): """Return a list of the element's inheritance lineage.""" -- 2.11.0