def register_app(app_names): """docstring for register_app""" module_names = [] for app_name in app_names: view_module_name = app_name + "." + "views" module_names.append(view_module_name) for module_name in module_names: try: __import__(module_name, globals(), locals()) module = sys.modules[module_name] members = [module.__dict__[m] for m in dir(module)] submodules = [m for m in members if inspect.ismodule(m)] for submodule in submodules: smembers = [submodule.__dict__[m] for m in dir(submodule)] sfunctions = [m for m in smembers if inspect.isfunction(m)] for func in sfunctions: if hasattr(func,'is_request_handler') and func.is_request_handler: path = func.path request_type = func.request_type router.register_path_handler(path, func, request_type) except ImportError, e: logging.error("Can't import " + module_name)
def register_handler_classes(handler_url_pairs): """docstring for register_handler_class""" for path, handler_class in handler_url_pairs: router.register_path_handler(path, handler_class)