have the plugin manager remove the scripts and directories from the server when a plugin is disabled

This commit is contained in:
Damien Churchill 2009-09-16 08:42:39 +00:00
parent 92ecb3fe87
commit b2390b8ff4
2 changed files with 21 additions and 0 deletions

View File

@ -86,7 +86,24 @@ class PluginManager(PluginManagerBase, component.Component):
log.info("Plugin has no web ui")
return
info = gather_info(plugin)
server = component.get("DelugeWeb").top_level
js = component.get("Javascript")
for directory in info["script_directories"]:
js.removeDirectory(directory, name.lower())
for script in info["scripts"]:
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
if script not in server.scripts:
continue
server.scripts.remove(script)
for script in info["debug_scripts"]:
script = "/js/%s/%s" % (name.lower(), os.path.basename(script))
if script not in server.debug_scripts:
continue
server.debug_scripts.remove(script)
super(PluginManager, self).disable_plugin(name)

View File

@ -255,6 +255,10 @@ class LookupResource(resource.Resource, component.Component):
paths = self.__paths.get(path, [])
paths.append(directory)
self.__paths[path] = paths
def removeDirectory(self, directory, path=""):
log.debug("Removing directory `%s`", directory)
self.__paths[path].remove(directory)
def getChild(self, path, request):
if hasattr(request, 'lookup_path'):