Tries to retrieve an isinstance of this model from the database
        given a value for a defined index. Return None in case of failure
192269
def get_by(cls, field, value):
        '''  '''
        redis = cls.get_redis()
        key = cls.cls_key()+':index_'+field

        id = redis.hget(key, value)

        if id:
            return cls.get(debyte_string(id))

        return None
497487
def object(self, session):
        ''''''
        if not hasattr(self, '_object'):
            pkname = self.model_type._meta.pkname()
            query = session.query(self.model_type).filter(**{pkname:
                                                             self.object_id})
            return query.items(callback=self.__set_object)
        else:
            return self._object
1350472
def get_models(cls, index, as_class=False):
        '''
        
        '''
        try:
            return cls._index_to_model[index] if as_class else cls._idx_name_to_mdl_to_mdlidx[index].keys()
        except KeyError:
            raise KeyError('Could not find any index named {}. Is this index defined in BUNGIESEARCH["INDICES"]?'.format(index))
287777
def index(fks, id):
    
    for i, j in fks.items():
        if fks[i][1] == id:
            return i
    return None
1008514
def find_by_index(self, cls, index_name, value):
        """"""
        query_args = {
            index_name + '__eq': DynamoMappings.map_index_val(value),
            'index': gsi_name(index_name)
        }

        final_results = []
        for db_result in self.get_class_table(cls).query_2(**query_args):
            obj = cls.from_data(db_result['value'])
            final_results.append(obj)

        return final_results
16775
def exists(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.exists(index=self._name, **kwargs)
148278
def get_instance_of(self, model_cls):
        
        for obj in self.data.values():
            if isinstance(obj, model_cls):
                return obj
        LOGGER.error('Context Not Found')
        raise Exception('Context Not Found')
201303
def _index(self, model):
        '''
        
        '''
        doc_type = model
        if not isinstance(model, str):
            doc_type = model.__table__.name

        index_name = doc_type
        if hasattr(model, "__msearch_index__"):
            index_name = model.__msearch_index__

        if doc_type not in self._indexs:
            self._indexs[doc_type] = Index(self._client, index_name, doc_type)
        return self._indexs[doc_type]
529151
def get_value_for_datastore(self, model_instance):
        """"""
        table_id = getattr(model_instance, self.table_fieldname, None)
        object_id = getattr(model_instance, self.object_fieldname, None)
        return table_id, object_id
598637
def get_instance(attr, value):
        
        for i in list(BrowserView.instances.values()):
            try:
                if getattr(i, attr) == value:
                    return i
            except AttributeError:
                break

        return None
463593
def get_from_instance(self, instance):
        
        # walk the attribute path to get the value. Similarly to Django, first
        # try getting the value from a dict, then as a attribute lookup, and
        # then as a list index
        for attr in self._path:
            try: # dict lookup
                instance = instance[attr]
            except (TypeError, AttributeError, KeyError, ValueError, IndexError):
                try: # attr lookup
                    instance = getattr(instance, attr)
                except (TypeError, AttributeError):
                    try:  # list-index lookup
                        instance = instance[int(attr)]
                    except (IndexError,  # list index out of range
                            ValueError,  # invalid literal for int()
                            KeyError,    # current is a dict without `int(bit)` key
                            TypeError):  # unsubscriptable object
                                raise VariableLookupError("Failed lookup for key [%s] in %r" % (attr, instance))

            if callable(instance):
                instance = instance()
            elif instance is None:  # no sense walking down the path any further
                return None

        return instance
309572
async def get_object_or_none(cls, db, **kwargs):
        
        async for obj in cls.filter_by(db, limit=1, **kwargs):
            return obj
        return None
1012320
@Override
    public Object getObject(int columnIndex) throws SQLException {
        checkColumnBounds(columnIndex);
        try {
            VoltType type = table.getColumnType(columnIndex - 1);
            if (type == VoltType.TIMESTAMP)
                return getTimestamp(columnIndex);
            else
                return table.get(columnIndex - 1, type);
        } catch (Exception x) {
            throw SQLError.get(x);
        }
    }
507171
def get_data_or_404(model, instance_id, kind=''):
    
    data = get_data(model, instance_id, kind)

    if not data:
        return abort(404)

    return data
1153893
def find_one(self, cls, id):
        """"""
        try:
            db_result = self.get_class_table(cls).lookup(id)
        except ItemNotFound:
            # according to docs, this shouldn't be required, but it IS
            db_result = None

        if not db_result:
            return None

        obj = cls.from_data(db_result['value'])
        return obj
934785
def class_instance_as_index(node):
    
    context = contextmod.InferenceContext()
    context.callcontext = contextmod.CallContext(args=[node])

    try:
        for inferred in node.igetattr("__index__", context=context):
            if not isinstance(inferred, bases.BoundMethod):
                continue

            for result in inferred.infer_call_result(node, context=context):
                if isinstance(result, nodes.Const) and isinstance(result.value, int):
                    return result
    except exceptions.InferenceError:
        pass
    return None
1169205
def contains(self, index: Union[SchemaKey, int, str]) -> bool:
        

        LOGGER.debug('SchemaCache.contains >>> index: %s', index)

        rv = None
        if isinstance(index, SchemaKey):
            rv = (index in self._schema_key2schema)
        elif isinstance(index, int) or (isinstance(index, str) and ':2:' not in index):
            rv = (int(index) in self._seq_no2schema_key)
        elif isinstance(index, str):
            rv = (schema_key(index) in self._schema_key2schema)
        else:
            rv = False

        LOGGER.debug('SchemaCache.contains <<< %s', rv)
        return rv