def process_form(form): """Processor for searchform on main page""" query = form.cleaned_data['query'] if not query: return [], [] providers_with_errors = [] searchproviders = [] for providerpath in settings.SEARCHPROVIDERS: modulestring, functionstring = providerpath.rsplit('.', 1) try: providermodule = importlib.import_module(modulestring) provider = getattr(providermodule, functionstring) searchproviders.append(provider(query)) except (AttributeError, ImportError) as error: providers_with_errors.append((providerpath, error)) _logger.error('Could not import %s', providerpath) except Exception as error: providers_with_errors.append((providerpath, error)) _logger.exception("Search provider raised unhandled exception: %s", providerpath) providers_with_result = has_results(searchproviders) if not providers_with_result and not providers_with_errors: fallback = providers.FallbackSearchProvider(query) if fallback.results: providers_with_result.append(fallback) return providers_with_result, providers_with_errors
def process_form(form): """Processor for searchform on main page""" query = form.cleaned_data['query'] if not query: return [] searchproviders = [ providers.RoomSearchProvider(query), providers.NetboxSearchProvider(query), providers.InterfaceSearchProvider(query), providers.VlanSearchProvider(query), providers.PrefixSearchProvider(query), providers.DevicegroupSearchProvider(query), providers.UnrecognizedNeighborSearchProvider(query) ] providers_with_result = has_results(searchproviders) if not providers_with_result: fallback = providers.FallbackSearchProvider(query) if fallback.results: providers_with_result.append(fallback) return providers_with_result