def setup(self, server, loader): """Setup the bundle following the setup process. Note that the bundles dictionary is passed to the setup method. It allows the bundle, when reading its meta-datas, to check its requirements. Return whether the bundle has been correctly setup. If the setup method returns False, the bundle won't be used in the final application. When the server is running, all installed bundles are read and setup following this process: 1. The bundle meta-datas are read from its file bundle.py. If this meta-datas indicates that the bundle can not be setup, the process stops 2. The controllers, models and views are loaded 3. The configuration is read and follows its own setup process """ self.meta_datas = self.read_meta_datas() # Check the bundle requirements for requirement in self.meta_datas.requirements: if requirement not in server.bundles: print("The {} bundle needs the {} one".format( self.name, requirement)) return False for plugin_name in self.meta_datas.plugins: self.server.plugin_manager.load_plugin(loader, plugin_name) self.server.plugin_manager.call("extend_autoloader", self.server, loader) self.server.plugin_manager.call_for(plugin_name, "bundle_autoload", self, loader) # Load the bundle's configuration self.config = Config(self.name) cfg_setup = self.config.setup(server) if not cfg_setup: return False # Load (with the autoloader) the Python modules loader.load_modules("controller", \ "bundles." + self.name + ".controllers") loader.load_modules("model", "bundles." + self.name + ".models") loader.load_modules("service", "bundles." + self.name + ".services") return True
def setup(self, server): """Setup the bundle following the setup process. Note that the bundles dictionary is passed to the setup method. It allows the bundle, when reading its meta-datas, to check its requirements. Return whether the bundle has been correctly setup. If the setup method returns False, the bundle won't be used in the final application. When the server is running, all installed bundles are read and setup following this process: 1. The bundle meta-datas are read from its file bundle.py. If this meta-datas indicates that the bundle can not be setup, the process stops 2. The controllers, models and views are loaded 3. The configuration is read and follows its own setup process """ self.meta_datas = self.read_meta_datas() # Check the bundle requirements for requirement in self.meta_datas.requirements: if requirement not in server.bundles: print("The {} bundle needs the {} one".format( self.name, requirement)) return False self.load_controllers(server) self.load_models(server) self.load_services(server) self.config = Config(self.name) cfg_setup = self.config.setup(server) if not cfg_setup: return False return True