def cleanup_extra_indexes(model_class):
 extra_indexes = model_class.compare_indexes().get('extra', None)
 if (not extra_indexes):
  return 0
 removed_count = 0
 c = model_class._get_collection()
 for extra_index in extra_indexes:
  try:
   c.drop_index(extra_index)
   LOG.debug('Dropped index %s for model %s.', extra_index, model_class.__name__)
   removed_count += 1
  except OperationFailure:
   LOG.warning('Attempt to cleanup index %s failed.', extra_index, exc_info=True)
 return removed_count

def cleanup_extra_indexes ( model_class ) : extra_indexes = model_class . compare_indexes ( ) . get ( 'extra' , None ) if ( not extra_indexes ) : return 0 removed_count = 0 c = model_class . _get_collection ( ) for extra_index in extra_indexes : try : c . drop_index ( extra_index ) LOG . debug ( 'Dropped index %s for model %s.' , extra_index , model_class . __name__ ) removed_count += 1 except OperationFailure : LOG . warning ( 'Attempt to cleanup index %s failed.' , extra_index , exc_info = True ) return removed_count
finds any extra indexes and removes those from mongodb .