def evaluate_filters(doc, filters):
 if isinstance(filters, dict):
  for (key, value) in filters.iteritems():
   f = get_filter(None, {key: value})
   if (not compare(doc.get(f.fieldname), f.operator, f.value)):
    return False
 elif isinstance(filters, (list, tuple)):
  for d in filters:
   f = get_filter(None, d)
   if (not compare(doc.get(f.fieldname), f.operator, f.value)):
    return False
 return True

def evaluate_filters ( doc , filters ) : if isinstance ( filters , dict ) : for ( key , value ) in filters . iteritems ( ) : f = get_filter ( None , { key : value } ) if ( not compare ( doc . get ( f . fieldname ) , f . operator , f . value ) ) : return False elif isinstance ( filters , ( list , tuple ) ) : for d in filters : f = get_filter ( None , d ) if ( not compare ( doc . get ( f . fieldname ) , f . operator , f . value ) ) : return False return True
returns true if doc matches filters .