st2common/st2common/models/db/__init__.py
def drop_obsolete_types_indexes(model_class):
    """
    Special class for droping offending "types" indexes for which support has
    been removed in mongoengine and MongoDB 3.4.
    For more info, see: http://docs.mongoengine.org/upgrade.html#inheritance
    """
    class_name = model_class.__name__

    LOG.debug('Dropping obsolete types index for model "%s"' % (class_name))
    collection = model_class._get_collection()
    collection.update({}, {'$unset': {'_types': 1}}, multi=True)

    info = collection.index_information()
    indexes_to_drop = [key for key, value in info.iteritems()
                       if '_types' in dict(value['key']) or 'types' in value]

    LOG.debug('Will drop obsolete types indexes for model "%s": %s' % (class_name,
                                                                       str(indexes_to_drop)))

    for index in indexes_to_drop:
        collection.drop_index(index)

    LOG.debug('Recreating indexes for model "%s"' % (class_name))
    model_class.ensure_indexes()

    Special class for droping offending "types" indexes for which support has
    been removed in mongoengine and MongoDB 3.4.
    For more info, see: http://docs.mongoengine.org/upgrade.html#inheritance
    
Special class for droping offending "types" indexes for which support has
been removed in mongoengine and MongoDB 3.4.
Special class for droping offending " types " indexes for which support has been removed in mongoengine and MongoDB 3 . 4 .
def drop_obsolete_types_indexes(model_class):
    class_name = model_class.__name__
    LOG.debug('Dropping obsolete types index for model "%s"' % (class_name))
    collection = model_class._get_collection()
    collection.update({}, {'$unset': {'_types': 1}}, multi=True)
    info = collection.index_information()
    indexes_to_drop = [key for key, value in info.iteritems()
                       if '_types' in dict(value['key']) or 'types' in value]
    LOG.debug('Will drop obsolete types indexes for model "%s": %s' % (class_name,
                                                                       str(indexes_to_drop)))
    for index in indexes_to_drop:
        collection.drop_index(index)
    LOG.debug('Recreating indexes for model "%s"' % (class_name))
    model_class.ensure_indexes()
def drop_obsolete_types_indexes ( model_class ) : class_name = model_class . __name__ LOG . debug ( 'Dropping obsolete types index for model "%s"' % ( class_name ) ) collection = model_class . _get_collection ( ) collection . update ( { } , { '$unset' : { '_types' : 1 } } , multi = True ) info = collection . index_information ( ) indexes_to_drop = [ key for key , value in info . iteritems ( ) if '_types' in dict ( value [ 'key' ] ) or 'types' in value ] LOG . debug ( 'Will drop obsolete types indexes for model "%s": %s' % ( class_name , str ( indexes_to_drop ) ) ) for index in indexes_to_drop : collection . drop_index ( index ) LOG . debug ( 'Recreating indexes for model "%s"' % ( class_name ) ) model_class . ensure_indexes ( )
Special class for droping offending "types" indexes for which support has
been removed in mongoengine and MongoDB 3.4.
Special class for droping offending " types " indexes for which support has been removed in mongoengine and MongoDB 3 . 4 .
"""
    Special class for droping offending "types" indexes for which support has
    been removed in mongoengine and MongoDB 3.4.
    For more info, see: http://docs.mongoengine.org/upgrade.html#inheritance
    """
model_class