def add_api_controllers(self, package_name, app): """ Search for UI controllers in `package_name` and add them to the webapp. """ from galaxy.web.base.controller import BaseAPIController from galaxy.web.base.controller import ControllerUnavailable package = import_module(package_name) controller_dir = package.__path__[0] for fname in os.listdir(controller_dir): if not (fname.startswith("_")) and fname.endswith(".py"): name = fname[:-3] module_name = package_name + "." + name try: module = import_module(module_name) except ControllerUnavailable, exc: log.debug("%s could not be loaded: %s" % (module_name, str(exc))) continue for key in dir(module): T = getattr(module, key) # Exclude classes such as BaseAPIController and BaseTagItemsController if inspect.isclass( T) and not key.startswith("Base") and issubclass( T, BaseAPIController): # By default use module_name, but allow controller to override name controller_name = getattr(T, "controller_name", name) controller = self._instantiate_controller(T, app) self.add_api_controller(controller_name, controller)
def add_api_controllers( self, package_name, app ): """ Search for UI controllers in `package_name` and add them to the webapp. """ from galaxy.web.base.controller import BaseAPIController from galaxy.web.base.controller import ControllerUnavailable package = import_module( package_name ) controller_dir = package.__path__[0] for fname in os.listdir( controller_dir ): if not( fname.startswith( "_" ) ) and fname.endswith( ".py" ): name = fname[:-3] module_name = package_name + "." + name try: module = import_module( module_name ) except ControllerUnavailable, exc: log.debug("%s could not be loaded: %s" % (module_name, str(exc))) continue for key in dir( module ): T = getattr( module, key ) # Exclude classes such as BaseAPIController and BaseTagItemsController if inspect.isclass( T ) and not key.startswith("Base") and issubclass( T, BaseAPIController ): # By default use module_name, but allow controller to override name controller_name = getattr( T, "controller_name", name ) controller = self._instantiate_controller( T, app ) self.add_api_controller( controller_name, controller )
def add_ui_controllers(self, package_name, app): """ Search for UI controllers in `package_name` and add them to the webapp. """ from galaxy.web.base.controller import BaseUIController from galaxy.web.base.controller import ControllerUnavailable package = import_module(package_name) controller_dir = package.__path__[0] for fname in os.listdir(controller_dir): if not (fname.startswith("_")) and fname.endswith(".py"): name = fname[:-3] module_name = package_name + "." + name try: module = import_module(module_name) except ControllerUnavailable, exc: log.debug("%s could not be loaded: %s" % (module_name, str(exc))) continue # Look for a controller inside the modules for key in dir(module): T = getattr(module, key) if inspect.isclass( T) and T is not BaseUIController and issubclass( T, BaseUIController): controller = self._instantiate_controller(T, app) self.add_ui_controller(name, controller)
def add_ui_controllers( self, package_name, app ): """ Search for UI controllers in `package_name` and add them to the webapp. """ from galaxy.web.base.controller import BaseUIController from galaxy.web.base.controller import ControllerUnavailable package = import_module( package_name ) controller_dir = package.__path__[0] for fname in os.listdir( controller_dir ): if not( fname.startswith( "_" ) ) and fname.endswith( ".py" ): name = fname[:-3] module_name = package_name + "." + name try: module = import_module( module_name ) except ControllerUnavailable, exc: log.debug("%s could not be loaded: %s" % (module_name, str(exc))) continue # Look for a controller inside the modules for key in dir( module ): T = getattr( module, key ) if inspect.isclass( T ) and T is not BaseUIController and issubclass( T, BaseUIController ): controller = self._instantiate_controller( T, app ) self.add_ui_controller( name, controller )