Aesthetics finalized for cmd_alias
Added RollbackImporter skeleton class to Evennia Server class
This commit is contained in:
parent
6015aca8db
commit
0980408e1c
2 changed files with 25 additions and 1 deletions
|
|
@ -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):
|
||||
"""
|
||||
|
|
|
|||
23
server.py
23
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 = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue