some comments in the module reload

This commit is contained in:
Brian S. Stephan 2010-07-30 06:56:37 -05:00
parent 0fc9a325fb
commit 6e86096f2b
1 changed files with 6 additions and 0 deletions

View File

@ -127,11 +127,17 @@ class Module(object):
def reload(self, connection, event, nick, userhost, replypath, what, admin_unlocked):
whats = what.split(' ')
if whats[0] == 'reload' and admin_unlocked:
# re-read and re-compile module from source on disk
reload(sys.modules[self.__module__])
# find the class declaration for the current module
for name, obj in inspect.getmembers(sys.modules[self.__module__]):
if inspect.isclass(obj) and str(obj).find(self.__module__) > 0:
# remove existing object from in-memory stuff
self.modlist.remove(self)
self.unregister_handlers()
# create new object, like how we did initially
obj(self.config, self.server, self.modlist)
# Utility method to do the proper type of reply (either to IRC, or as a return