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.GeneralViewSetMixin[source]

Bases: object

Mixin for both typeclass- and non-typeclass entities.

get_serializer_class()[source]

Allow different serializers for certain actions.

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

Bases: evennia.web.api.views.GeneralViewSetMixin

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.

The set_atribute action 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.

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

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

The Object is the parent for all in-game entities that have a location (rooms, exits, characters etc).

serializer_class

alias of evennia.web.api.serializers.ObjectDBSerializer

queryset
filterset_class

alias of evennia.web.api.filters.ObjectDBFilterSet

list_serializer_class

alias of evennia.web.api.serializers.ObjectListSerializer

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

Bases: evennia.web.api.views.ObjectDBViewSet

Characters are a type of Object commonly used as player avatars in-game.

queryset
list_serializer_class

alias of evennia.web.api.serializers.ObjectListSerializer

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

Bases: evennia.web.api.views.ObjectDBViewSet

Rooms indicate discrete locations in-game.

queryset
list_serializer_class

alias of evennia.web.api.serializers.ObjectListSerializer

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

Bases: evennia.web.api.views.ObjectDBViewSet

Exits are objects with a destination and allows for traversing from one location to another.

queryset
list_serializer_class

alias of evennia.web.api.serializers.ObjectListSerializer

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

Accounts represent the players connected to the game

serializer_class

alias of evennia.web.api.serializers.AccountSerializer

queryset
filterset_class

alias of evennia.web.api.filters.AccountDBFilterSet

list_serializer_class

alias of evennia.web.api.serializers.AccountListSerializer

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

Scripts are meta-objects for storing system data, running timers etc. They have no in-game existence.

serializer_class

alias of evennia.web.api.serializers.ScriptDBSerializer

queryset
filterset_class

alias of evennia.web.api.filters.ScriptDBFilterSet

list_serializer_class

alias of evennia.web.api.serializers.ScriptListSerializer

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

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

Database-stored help entries. Note that command auto-help and file-based help entries are not accessible this way.

serializer_class

alias of evennia.web.api.serializers.HelpSerializer

queryset
filterset_class

alias of evennia.web.api.filters.HelpFilterSet

list_serializer_class

alias of evennia.web.api.serializers.HelpListSerializer

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