From 0980408e1c797ab1a414372f57c49167106bc391 Mon Sep 17 00:00:00 2001 From: Michael King Date: Mon, 11 Jun 2007 15:49:05 +0000 Subject: [PATCH] Aesthetics finalized for cmd_alias Added RollbackImporter skeleton class to Evennia Server class --- commands/objmanip.py | 3 ++- server.py | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/commands/objmanip.py b/commands/objmanip.py index b0fcc4682..22b22eb0d 100644 --- a/commands/objmanip.py +++ b/commands/objmanip.py @@ -110,11 +110,12 @@ def cmd_alias(cdat): duplicates = Attribute.objects.filter(attr_name="ALIAS").filter(attr_value=eq_args[1]) if duplicates: - session.msg("Alias already exists.") + session.msg("Alias '%s' already exists." % (eq_args[1],)) return else: if pobject.controls_other(target): target.set_attribute('ALIAS', eq_args[1]) + session.msg("Alias %s (%s) added." % (target.get_name(), eq_args[1])) def cmd_wipe(cdat): """ diff --git a/server.py b/server.py index 5fbd3cf39..423be4011 100755 --- a/server.py +++ b/server.py @@ -21,6 +21,29 @@ import initial_setup class EvenniaService(service.Service): + class RollbackImporter(object): + def __init__(self): + "Creates an instance and installs as the global importer" + self.previousModules = sys.modules.copy() + self.realImport = __builtin__.__import__ + __builtin__.__import__ = self._import + self.newModules = {} + + def _import(self, name, globals=None, locals=None, fromlist=[]): + result = apply(self.realImport, (name, globals, locals, fromlist)) + self.NewModules[name] = 1 + return result + + def uninstall(self): + for modname in self.newModules.keys(): + if not self.previousModules.has_key(modname): + # Force reload when modname next imported + del(sys.modules[modname]) + __builtin__.__import__ = self.realImport + + def reloadAll(self): + pass + def __init__(self, filename="blah"): log.startLogging(open(settings.LOGFILE, 'w')) self.cmd_alias_list = {}