def _filterComponents(self, comps, keys, query): """ Returns a list of components where one of the attributes in keys contains the query (case-insensitive). @type comps: SearchResults @param comps: All the Components for this query @type keys: List @param keys: List of strings of fields that we are filtering on @type query: String @param query: Search Term @rtype: List @return: List of Component Info objects that match the query """ results = [] query = query.lower() for comp in comps: keep = False for key in keys: # non searchable fields if key in ('uid', 'uuid', 'events', 'status', 'severity'): continue val = getattr(comp, key, None) if not val: continue if callable(val): val = val() if IInfo.providedBy(val): val = val.name if query in str(val).lower(): keep = True break if keep: results.append(comp) return results
def componentSortKey(parent): val = getattr(parent, sort) if val: if isinstance(val, list): val = val[0] if callable(val): val = val() if IInfo.providedBy(val): val = val.name return val
def componentSortKey(parent): val = getattr(parent, sort) if val: if isinstance(val, list): val = val[0] if callable(val): val = val() if IInfo.providedBy(val): val = val.name return pad_numeric_values_for_indexing(val)
def getValue(obj): key = obj.getPrimaryPath() if key in savedValues: value = savedValues[key] else: value = getattr(IInfo(obj), orderby) if callable(value): value = value() # if an info object is returned then sort by the name if IInfo.providedBy(value): value = value.name.lower() savedValues[key] = value return value