From: Jeremy Stanley Date: Thu, 9 Nov 2017 09:54:38 +0000 (+0000) Subject: Make new-style facet deletion more robust X-Git-Tag: 0.0.1~125 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=6161f58fe66ce3cbfa236625555ce54280a0dad8;p=mudpy.git 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. --- 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."""