def __init__(self, plugins=[]): resource.Resource.__init__(self) self.pluginsManager = PluginsManager() for plugin in plugins: instances = self.pluginsManager.createModuleInstanceFromQuery("WHIA/Actuator", **plugin) for i in instances: self.putChild(i.name, i)
class WebDomoServer(resource.Resource): def __init__(self, plugins=[]): resource.Resource.__init__(self) self.pluginsManager = PluginsManager() for plugin in plugins: instances = self.pluginsManager.createModuleInstanceFromQuery("WHIA/Actuator", **plugin) for i in instances: self.putChild(i.name, i) def render_GET(self, request): return json.dumps(self.children.keys()) def getChild(self, path, request): if path == "": return self else: if path in self.children.keys(): return resource.Resource.getChild(self, path, request) else: '''TODO: se master vedi se un qualche slave ha il plugin giusto e invia la richiesta''' return PageNotFoundError()