Uses get() to return an object or the value of <this> argument
    if object does not exist.

    If the <this> argument if not provided None would be returned.
    <model> can be either a QuerySet instance or a class.
511284
def get_object_or_this(model, this=None, *args, **kwargs):
    

    return get_object_or_None(model, *args, **kwargs) or this
492556
def get_queryset(self, queryset=None):
        
        serializer = self.get_serializer()
        return getattr(self, 'queryset', serializer.Meta.model.objects.all())
635978
def get_queryset(self):
        """"""
        if self.queryset is None and not self.model:
            try:
                ModelClass = apps.get_model(self.kwargs.get('app'), self.kwargs.get('model'))
                return ModelClass._default_manager.all()
            except LookupError:
                raise Http404()
        return super().get_queryset()
356128
def get_object(self, queryset=None):
        
        # Use a custom queryset if provided; this is required for subclasses
        # like DateDetailView
        if queryset is None:
            queryset = self.get_queryset()

        path = self.kwargs.get('path', None)

        # Next, try looking up by path.
        if path is not None:
            queryset = queryset.filter(**FileNode.objects.get_filter_args_with_path(
                for_self=True, path=path))
            try:
                obj = queryset.get()
            except FileNode.DoesNotExist:
                raise Http404(_(u"No %(verbose_name)s found matching the query") %
                              {'verbose_name': queryset.model._meta.verbose_name})
            return obj

        return super(FileNodeDetailView, self).get_object(queryset)
423270
public final T get(Object... args) {
        //Grab a read lock to try retrieving the object
        this.readLock.lock();
        try {

            //See if the object already exists
            T value = this.retrieve(args);
            if (this.invalid(value, args)) {
                //Switch to a write lock
                this.readLock.unlock();
                this.writeLock.lock();
                
                //Check if it exists now, create it if it doesn't
                try {
                    value = this.retrieve(args);
                
                    if (this.invalid(value, args)) {
                        value = this.create(args);
                        
                        if (this.logger.isDebugEnabled()) {
                            this.logger.debug("Created new Object='" + value + "'");
                        }
                    }
                    else if (this.logger.isDebugEnabled()) {
                        this.logger.debug("Using retrieved Object='" + value + "'");
                    }
                }
                finally {
                    //switch back to the read lock
                    this.readLock.lock();
                    this.writeLock.unlock();
                }
            }
            else if (this.logger.isDebugEnabled()) {
                this.logger.debug("Using retrieved Object='" + value + "'");
            }

            return value;
        }
        finally {
            this.readLock.unlock();
        }
    }
53295
def get_or_create(self, **kwargs):
        
        assert kwargs, \
            'get_or_create() must be passed at least one keyword argument'
        defaults = kwargs.pop('defaults', {})
        lookup = kwargs.copy()
        #TODO: check fields
        try:
            return self.get(**lookup), False
        except self.model.DoesNotExist:
            params = dict([(k, v) for k, v in kwargs.items() if '__' not in k])
            params.update(defaults)
            obj = self.model(**params)
            obj.save(force_insert=True)
            return obj, True
399225
def get(self, *args, **kwargs):
        
        clone = self.filter(*args, **kwargs)

        if self.query.can_filter():
            clone = clone.order_by()

        num = len(clone)

        if num == 1:
            return clone._result_cache[0]
        if not num:
            raise self.resource.DoesNotExist(
                "%s matching query does not exist. "
                "Lookup parameters were %s" %
                (self.resource._meta.resource_name, kwargs))

        raise self.resource.MultipleObjectsReturned(
            "get() returned more than one %s -- it returned %s! "
            "Lookup parameters were %s" %
            (self.resource._meta.resource_name, num, kwargs))
1159233
def get_object(self, queryset=None):
        

        schema = manager.get_schema()
        vid = None
        if self.request.GET.get('vid') and self.request.user.is_staff and \
                self.request.user.is_active:
            try:
                schema = 'public'
                vid = int(self.request.GET.get('vid'))
                queryset = self.model.normal.filter(vid=vid)
            except ValueError:
                pass

        with manager.SwitchSchema(schema):
            # Use a custom queryset if provided
            if queryset is None:
                queryset = self.get_queryset()

            # Next, try looking up by primary key.
            pk = self.kwargs.get(self.pk_url_kwarg, None)
            slug = self.kwargs.get(self.slug_url_kwarg, None)
            if pk is not None:
                if vid:
                    queryset = queryset.filter(vid=vid)
                else:
                    queryset = queryset.filter(object_id=pk)

            # Next, try looking up by slug.
            elif slug is not None:
                slug_field = self.get_slug_field()
                queryset = queryset.filter(**{slug_field: slug})

            # If none of those are defined, it's an error.
            else:
                raise AttributeError(u"View %s must be called with "
                                     u"either an object pk or a slug."
                                     % self.__class__.__name__)

            try:
                obj = queryset.get()
            except queryset.model.DoesNotExist:
                raise http.Http404(
                        u"No %(verbose_name)s found matching the query" %
                         {'verbose_name': queryset.model._meta.verbose_name})

        return obj
948711
def get(self, *args, **kwargs) -> "QuerySet":
        
        queryset = self.filter(*args, **kwargs)
        queryset._limit = 2
        queryset._get = True
        return queryset
314237
def get(self, **kwargs):
        
        for chain in self.chains:
            for key in kwargs:
                getter_name = "get_"+key
                # scan all possible getters
                if (hasattr(chain, getter_name)):
                    getter = getattr(chain, getter_name) # e.g. "get_address"
                    if (getter() == kwargs[key]):
                        return chain
        return None
154793
def get_object(self, queryset=None):
        
        if queryset is None:
            queryset = self.get_queryset()

        slug = self.kwargs[self.slug_url_kwarg]
        choices = self.get_language_choices()

        obj = None
        using_fallback = False
        prev_choices = []
        for lang_choice in choices:
            try:
                # Get the single item from the filtered queryset
                # NOTE. Explicitly set language to the state the object was fetched in.
                filters = self.get_translated_filters(slug=slug)
                obj = queryset.translated(lang_choice, **filters).language(lang_choice).get()
            except ObjectDoesNotExist:
                # Translated object not found, next object is marked as fallback.
                using_fallback = True
                prev_choices.append(lang_choice)
            else:
                break

        if obj is None:
            tried_msg = ", tried languages: {0}".format(", ".join(choices))
            error_message = translation.ugettext("No %(verbose_name)s found matching the query") % {'verbose_name': queryset.model._meta.verbose_name}
            raise Http404(error_message + tried_msg)

        # Object found!
        if using_fallback:
            # It could happen that objects are resolved using their fallback language,
            # but the actual translation also exists. Either that means this URL should
            # raise a 404, or a redirect could be made as service to the users.
            # It's possible that the old URL was active before in the language domain/subpath
            # when there was no translation yet.
            for prev_choice in prev_choices:
                if obj.has_translation(prev_choice):
                    # Only dispatch() and render_to_response() can return a valid response,
                    # By breaking out here, this functionality can't be broken by users overriding render_to_response()
                    raise FallbackLanguageResolved(obj, prev_choice)

        return obj
567301
def get_object(self, queryset=None):
        
        try:
            obj = self.get_queryset()
        except self.model.DoesNotExist:
            raise Http404()
        self.check_object_permissions(self.request, obj)
        return obj
221466
def get_model(self):
        
        if hasattr(self, 'model') and self.model:
            return self.model
        # Give me a "none" queryset
        try:
            none = self.get_queryset().none()
            return none.model
        except Exception:
            raise ImproperlyConfigured(
                "Integrator: Unable to determine the model with this queryset."
                " Please add a `model` property")
1271837
def get_object_or_none(klass, *args, **kwargs):
    
    queryset = _get_queryset(klass)
    try:
        return queryset.get(*args, **kwargs)
    except:  # noqa: E722
        return None
642484
def get_object(self, queryset=None):
        
        if queryset is None:
            queryset = self.get_queryset()

        try:
            return queryset.get(user__pk=self.request.user.pk)
        except ObjectDoesNotExist:
            raise Http404
637892
def get_object_or_404(self, queryset, *filter_args, **filter_kwargs):
        
        if isinstance(queryset, CachedQueryset):
            try:
                return queryset.get(*filter_args, **filter_kwargs)
            except queryset.model.DoesNotExist:
                raise Http404(
                    'No %s matches the given query.' % queryset.model)
        else:
            return get_object_or_404(queryset, *filter_args, **filter_kwargs)
443591
def get_object(self, view_name, view_args, view_kwargs):
        

        # default lookup from rest_framework.relations.HyperlinkedRelatedField
        lookup_value = view_kwargs[self.lookup_url_kwarg]
        kwargs = {self.lookup_url_kwarg: lookup_value}

        # multi-level lookup
        for parent_lookup_kwarg in list(self.parent_lookup_kwargs.keys()):
            lookup_value = view_kwargs[parent_lookup_kwarg]
            kwargs.update({self.parent_lookup_kwargs[parent_lookup_kwarg]: lookup_value})

        return self.get_queryset().get(**kwargs)