+
+ # the files dict must exist and filename needs to be read-only
+ if not hasattr(self, "files") or not ( self.filename in self.files and self.files[self.filename].is_writeable() ):
+
+ # clear out all read-only files
+ if hasattr(self, "files"):
+ for data_filename in self.files.keys():
+ if not self.files[data_filename].is_writeable():
+ del self.files[data_filename]
+
+ # start loading from the initial file
+ DataFile(self.filename, self)
+
+ # make a list of inactive avatars
+ inactive_avatars = []
+ for account in self.categories["account"].values():
+ inactive_avatars += [ (self.contents[x]) for x in account.getlist("avatars") ]
+ for user in self.userlist:
+ if user.avatar in inactive_avatars:
+ inactive_avatars.remove(user.avatar)
+
+ # go through all elements to clear out inactive avatar locations
+ for element in self.contents.values():
+ location = element.get("location")
+ if element in inactive_avatars and location:
+ if location in self.contents and element.key in self.contents[location].contents:
+ del self.contents[location].contents[element.key]
+ element.set("default_location", location)
+ element.remove_facet("location")
+
+ # another pass to straighten out all the element contents
+ for element in self.contents.values():
+ element.update_location()
+ element.clean_contents()
+