django_socio_grpc.generics

Module Contents

Classes

GenericService

Base class for all other generic services.

CreateService

Concrete service for creating a model instance that provides a Create() handler.

ListService

Concrete service for listing a queryset that provides a List() handler.

StreamService

Concrete service for listing one by one on streaming a queryset that provides a Stream() handler.

RetrieveService

Concrete service for retrieving a model instance that provides a Retrieve() handler.

DestroyService

Concrete service for deleting a model instance that provides a Destroy() handler.

UpdateService

Concrete service for updating a model instance that provides a Update() handler.

ListCreateService

Concrete service for listing a queryset that provides a List() and Create() handler.

ReadOnlyModelService

Concrete service that provides default List() and Retrieve() handlers.

ModelService

Concrete service that provides default Create(), Retrieve(), Update(), Destroy() and List() handlers.

AsyncCreateService

Concrete service for creating a model instance that provides a Create() handler.

AsyncListService

Concrete service for listing a queryset that provides a List() handler.

AsyncStreamService

Concrete service for listing one by one on streaming a queryset that provides a Stream() handler.

AsyncRetrieveService

Concrete service for retrieving a model instance that provides a Retrieve() handler.

AsyncDestroyService

Concrete service for deleting a model instance that provides a Destroy() handler.

AsyncUpdateService

Concrete service for updating a model instance that provides a Update() handler.

AsyncListCreateService

Concrete service for listing a queryset that provides a List() and Create() handler.

AsyncReadOnlyModelService

Concrete service that provides default List() and Retrieve() handlers.

AsyncModelService

Concrete service that provides default Create(), Retrieve(), Update(), Destroy() and List() handlers.

Data

logger

API

django_socio_grpc.generics.logger

‘getLogger(…)’

class django_socio_grpc.generics.GenericService(**kwargs)

Bases: django_socio_grpc.services.Service

Base class for all other generic services.

Initialization

Set kwargs as self attributes.

queryset: django.db.models.query.QuerySet | None

None

serializer_class: django_socio_grpc.proto_serializers.ProtoSerializer | None

None

lookup_field: str | None

None

lookup_request_field: str | None

None

filter_backends: list[rest_framework.filters.BaseFilterBackend]

None

pagination_class: rest_framework.pagination.BasePagination | None

None

service_name: str | None

None

classmethod get_service_name()
get_queryset()

Get the list of items for this service. This must be an iterable, and may be a queryset. Defaults to using self.queryset.

If you are overriding a handler method, it is important that you call get_queryset() instead of accessing the queryset attribute as queryset will get evaluated only once.

Override this to provide dynamic behavior, for example::

def get_queryset(self):
    if self.action == 'ListSpecialUser':
        return SpecialUser.objects.all()
    return super().get_queryset()
get_serializer_class()

Return the class to use for the serializer. Defaults to using self.serializer_class.

get_lookup_request_field(queryset=None)
get_object()

Returns an object instance that should be used for detail services. Defaults to using the lookup_field parameter to filter the base queryset.

async aget_object()

Returns an object instance that should be used for detail services. Defaults to using the lookup_field parameter to filter the base queryset.

get_serializer(*args, **kwargs)

Return the serializer instance that should be used for validating and deserializing input, and for serializing output.

async aget_serializer(*args, **kwargs)
get_serializer_context()

Extra context provided to the serializer class. Defaults to including grpc_request, grpc_context, and service keys.

filter_queryset(queryset)

Given a queryset, filter it, returning a new queryset.

async afilter_queryset(queryset)

Given a queryset, filter it, returning a new queryset.

property paginator

The paginator instance associated with the view, or None.

paginate_queryset(queryset)

Return a single page of results, or None if pagination is disabled.

class django_socio_grpc.generics.CreateService(**kwargs)

Bases: django_socio_grpc.mixins.CreateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for creating a model instance that provides a Create() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.ListService(**kwargs)

Bases: django_socio_grpc.mixins.ListModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing a queryset that provides a List() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.StreamService(**kwargs)

Bases: django_socio_grpc.mixins.StreamModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing one by one on streaming a queryset that provides a Stream() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.RetrieveService(**kwargs)

Bases: django_socio_grpc.mixins.RetrieveModelMixin, django_socio_grpc.generics.GenericService

Concrete service for retrieving a model instance that provides a Retrieve() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.DestroyService(**kwargs)

Bases: django_socio_grpc.mixins.DestroyModelMixin, django_socio_grpc.generics.GenericService

Concrete service for deleting a model instance that provides a Destroy() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.UpdateService(**kwargs)

Bases: django_socio_grpc.mixins.UpdateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for updating a model instance that provides a Update() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.ListCreateService(**kwargs)

Bases: django_socio_grpc.mixins.ListModelMixin, django_socio_grpc.mixins.CreateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing a queryset that provides a List() and Create() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.ReadOnlyModelService(**kwargs)

Bases: django_socio_grpc.mixins.RetrieveModelMixin, django_socio_grpc.mixins.ListModelMixin, django_socio_grpc.generics.GenericService

Concrete service that provides default List() and Retrieve() handlers.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.ModelService(**kwargs)

Bases: django_socio_grpc.mixins.CreateModelMixin, django_socio_grpc.mixins.RetrieveModelMixin, django_socio_grpc.mixins.UpdateModelMixin, django_socio_grpc.mixins.DestroyModelMixin, django_socio_grpc.mixins.ListModelMixin, django_socio_grpc.mixins.PartialUpdateModelMixin, django_socio_grpc.generics.GenericService

Concrete service that provides default Create(), Retrieve(), Update(), Destroy() and List() handlers.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncCreateService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncCreateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for creating a model instance that provides a Create() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncListService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncListModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing a queryset that provides a List() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncStreamService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncStreamModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing one by one on streaming a queryset that provides a Stream() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncRetrieveService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncRetrieveModelMixin, django_socio_grpc.generics.GenericService

Concrete service for retrieving a model instance that provides a Retrieve() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncDestroyService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncDestroyModelMixin, django_socio_grpc.generics.GenericService

Concrete service for deleting a model instance that provides a Destroy() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncUpdateService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncUpdateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for updating a model instance that provides a Update() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncListCreateService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncListModelMixin, django_socio_grpc.mixins.AsyncCreateModelMixin, django_socio_grpc.generics.GenericService

Concrete service for listing a queryset that provides a List() and Create() handler.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncReadOnlyModelService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncRetrieveModelMixin, django_socio_grpc.mixins.AsyncListModelMixin, django_socio_grpc.generics.GenericService

Concrete service that provides default List() and Retrieve() handlers.

Initialization

Set kwargs as self attributes.

class django_socio_grpc.generics.AsyncModelService(**kwargs)

Bases: django_socio_grpc.mixins.AsyncCreateModelMixin, django_socio_grpc.mixins.AsyncRetrieveModelMixin, django_socio_grpc.mixins.AsyncUpdateModelMixin, django_socio_grpc.mixins.AsyncDestroyModelMixin, django_socio_grpc.mixins.AsyncListModelMixin, django_socio_grpc.mixins.AsyncPartialUpdateModelMixin, django_socio_grpc.generics.GenericService

Concrete service that provides default Create(), Retrieve(), Update(), Destroy() and List() handlers.

Initialization

Set kwargs as self attributes.