示例#1
0
    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 _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
示例#3
0
 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)
示例#5
0
 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
示例#6
0
 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
示例#7
0
 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