From 792b3c9282514320e80be55e3a0a2152200f2e92 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sun, 20 Apr 2014 18:11:41 +0200 Subject: [PATCH] Some cleanup code fixes. --- src/comms/models.py | 2 ++ src/objects/models.py | 4 +++ src/players/models.py | 3 ++ src/scripts/models.py | 1 + src/typeclasses/models.py | 3 -- src/utils/batchprocessors.py | 64 ------------------------------------ 6 files changed, 10 insertions(+), 67 deletions(-) diff --git a/src/comms/models.py b/src/comms/models.py index 0b9be1964c..9e18dbc2e5 100644 --- a/src/comms/models.py +++ b/src/comms/models.py @@ -433,5 +433,7 @@ class ChannelDB(TypedObject): Deletes channel while also cleaning up channelhandler """ super(ChannelDB, self).delete() + _GA(self, "attributes").clear() + _GA(self, "aliases").clear() from src.comms.channelhandler import CHANNELHANDLER CHANNELHANDLER.update() diff --git a/src/objects/models.py b/src/objects/models.py index 8439c4dd65..45bd90052c 100644 --- a/src/objects/models.py +++ b/src/objects/models.py @@ -780,6 +780,10 @@ class ObjectDB(TypedObject): _GA(self, "clear_exits")() # Clear out any non-exit objects located within the object _GA(self, "clear_contents")() + _GA(self, "attributes").clear() + _GA(self, "nicks").clear() + _GA(self, "aliases").clear() + # Perform the deletion of the object super(ObjectDB, self).delete() return True diff --git a/src/players/models.py b/src/players/models.py index 8ef09c7f1a..e33319ec99 100644 --- a/src/players/models.py +++ b/src/players/models.py @@ -417,6 +417,9 @@ class PlayerDB(TypedObject, AbstractUser): self.unpuppet_object(session.sessid) session.sessionhandler.disconnect(session, reason=_("Player being deleted.")) self.scripts.stop() + _GA(self, "attributes").clear() + _GA(self, "nicks").clear() + _GA(self, "aliases").clear() super(PlayerDB, self).delete(*args, **kwargs) def execute_cmd(self, raw_string, sessid=None): diff --git a/src/scripts/models.py b/src/scripts/models.py index c577618e09..85e0af347d 100644 --- a/src/scripts/models.py +++ b/src/scripts/models.py @@ -184,4 +184,5 @@ class ScriptDB(TypedObject): if self.delete_iter > 0: return self.delete_iter += 1 + _GA(self, "attributes").clear() super(ScriptDB, self).delete() diff --git a/src/typeclasses/models.py b/src/typeclasses/models.py index ac8ea55503..03f7be620a 100644 --- a/src/typeclasses/models.py +++ b/src/typeclasses/models.py @@ -1130,9 +1130,6 @@ class TypedObject(SharedMemoryModel): def delete(self): "Cleaning up handlers on the typeclass level" - _GA(self, "attributes").clear() - _GA(self, "nicks").clear() - _GA(self, "aliases").clear() _GA(self, "permissions").clear() super(TypedObject, self).delete() diff --git a/src/utils/batchprocessors.py b/src/utils/batchprocessors.py index aec7033f71..bff1a5f135 100644 --- a/src/utils/batchprocessors.py +++ b/src/utils/batchprocessors.py @@ -295,70 +295,6 @@ class BatchCommandProcessor(object): commands = [c for c in commands if c] return commands -# #helper function -# def identify_line(line): -# """ -# Identifies the line type (comment, commanddef or empty) -# """ -# try: -# if line.strip().startswith("#INSERT"): -# return "insert" -# elif line.strip()[0] == '#': -# return "comment" -# else: -# return "commanddef" -# except IndexError: -# return "empty" -# -# #read the indata, if possible. -# lines = read_batchfile(pythonpath, file_ending='.ev') -# -# #line = utils.to_unicode(line) -# if not lines: -# return None -# -# commands = [] -# curr_cmd = "" -# -# #purge all superfluous whitespace and newlines from lines -# reg1 = re.compile(r"\s+") -# lines = [reg1.sub(" ", l) for l in lines] -# -# #parse all command definitions into a list. -# for line in lines: -# -# typ = identify_line(line) -# -# if typ == "commanddef": -# curr_cmd += line -# elif typ == "empty" and curr_cmd: -# curr_cmd += "\r\n" -# elif typ == "insert": -# # note that we are not safeguarding for -# # cyclic imports here! -# if curr_cmd: -# commands.append(curr_cmd.strip()) -# curr_cmd = "" -# filename = line.lstrip("#INSERT").strip() -# insert_commands = self.parse_file(filename) -# if insert_commands is None: -# insert_commands = ["{rINSERT ERROR: %s{n" % filename] -# commands.extend(insert_commands) -# else: #comment -# if curr_cmd: -# commands.append(curr_cmd.strip()) -# curr_cmd = "" -# if curr_cmd: -# commands.append(curr_cmd.strip()) -# -# #second round to clean up now merged line edges etc. -# reg2 = re.compile(r"[ \t\f\v]+") -# commands = [reg2.sub(" ", c) for c in commands] -# -# #remove eventual newline at the end of commands -# commands = [c.strip('\r\n') for c in commands] -# return commands - #------------------------------------------------------------ #