evennia.web.api.views

Views are the functions that are called by different url endpoints. The Django Rest Framework provides collections called ‘ViewSets’, which can generate a number of views for the common CRUD operations.

class evennia.web.api.views.TypeclassViewSetMixin[source]

Bases: object

This mixin adds some shared functionality to each viewset of a typeclass. They all use the same permission classes and filter backend. You can override any of these in your own viewsets.

permission_classes = [<class 'evennia.web.api.permissions.EvenniaPermission'>]
filter_backends = [<class 'django_filters.rest_framework.backends.DjangoFilterBackend'>]
set_attribute(request, pk=None)[source]

This is an example of a custom action added to a viewset. Based on the name of the method, it will create a default url_name (used for reversing) and url_path. The ‘pk’ argument is automatically passed to this action because it has a url path of the format <object type>/:pk/set-attribute. The get_object method is automatically set in the expected viewset classes that will inherit this, using the pk that’s passed along to retrieve the object.

This action will set an attribute if the db_value is defined, or remove it if no db_value is provided.

class evennia.web.api.views.ObjectDBViewSet(**kwargs)[source]

Bases: evennia.web.api.views.TypeclassViewSetMixin, rest_framework.viewsets.ModelViewSet

An example of a basic viewset for all ObjectDB instances. It declares the serializer to use for both retrieving and changing/creating/deleting instances. Serializers are similar to django forms, used for the transmitting of data (typically json).

serializer_class

alias of evennia.web.api.serializers.ObjectDBSerializer

queryset
filterset_class

alias of evennia.web.api.filters.ObjectDBFilterSet

basename = None
description = None
detail = None
name = None
suffix = None
class evennia.web.api.views.CharacterViewSet(**kwargs)[source]

Bases: evennia.web.api.views.ObjectDBViewSet

This overrides the queryset to only retrieve Character objects based on your DefaultCharacter typeclass path.

queryset
basename = None
description = None
detail = None
name = None
suffix = None
class evennia.web.api.views.RoomViewSet(**kwargs)[source]

Bases: evennia.web.api.views.ObjectDBViewSet

Viewset for Room objects

queryset
basename = None
description = None
detail = None
name = None
suffix = None
class evennia.web.api.views.ExitViewSet(**kwargs)[source]

Bases: evennia.web.api.views.ObjectDBViewSet

Viewset for Exit objects

queryset
basename = None
description = None
detail = None
name = None
suffix = None
class evennia.web.api.views.AccountDBViewSet(**kwargs)[source]

Bases: evennia.web.api.views.TypeclassViewSetMixin, rest_framework.viewsets.ModelViewSet

Viewset for Account objects

serializer_class

alias of evennia.web.api.serializers.AccountSerializer

queryset
filterset_class

alias of evennia.web.api.filters.AccountDBFilterSet

basename = None
description = None
detail = None
name = None
suffix = None
class evennia.web.api.views.ScriptDBViewSet(**kwargs)[source]

Bases: evennia.web.api.views.TypeclassViewSetMixin, rest_framework.viewsets.ModelViewSet

Viewset for Script objects

serializer_class

alias of evennia.web.api.serializers.ScriptDBSerializer

queryset
filterset_class

alias of evennia.web.api.filters.ScriptDBFilterSet

basename = None
description = None
detail = None
name = None
suffix = None