Kinto-Core maps URLs, endpoints and permissions to resources using ViewSets.

Since a resource defines two URLs with several HTTP methods, a view set can be considered as a set of rules for registring the resource views into the routing mechanism of Pyramid.

To use Kinto-Core in a basic fashion, there is no need to understand how viewsets work in full detail.

Override defaults

Viewsets defaults can be overriden by passing arguments to the kinto.core.resource.register() class decorator:

from kinto.core import resource

class Resource(resource.UserResource):
    schema = BookmarkSchema


In case this isn’t enough, the kinto.core.resource.viewset.ViewSet class can be subclassed and specified during registration:

from kinto.core import resource

class NoSchemaViewSet(resource.ViewSet):

    def get_record_schema(self, resource_cls, method):
        simple_mapping = colander.MappingSchema(unknown='preserve')
        return simple_mapping

class Resource(resource.UserResource):
    schema = BookmarkSchema

ViewSet class

class kinto.core.resource.viewset.ViewSet(**kwargs)

The default ViewSet object.

A viewset contains all the information needed to register any resource in the Cornice registry.

It provides the same features as cornice.resource(), except that it is much more flexible and extensible.


Update viewset attributes with provided values.

get_view_arguments(endpoint_type, resource_cls, method)

Return the Pyramid/Cornice view arguments for the given endpoint type and method.

  • endpoint_type (str) – either “collection” or “record”.
  • resource_cls – the resource class.
  • method (str) – the HTTP method.
get_record_schema(resource_cls, method)

Return the Cornice schema for the given method.

get_view(endpoint_type, method)

Return the view method name located on the resource object, for the given type and method.

  • For collections, this will be “collection_{method|lower}
  • For records, this will be “{method|lower}.

Returns the name of the resource.

get_service_name(endpoint_type, resource_cls)

Returns the name of the service, depending a given type and resource.

is_endpoint_enabled(endpoint_type, resource_name, method, settings)

Returns if the given endpoint is enabled or not.

Uses the settings to tell so.

class kinto.core.resource.viewset.ShareableViewSet(**kwargs)

A ShareableViewSet will register the given resource with a schema that supports permissions.

The views will rely on dynamic permissions (e.g. create with PUT if record does not exist), and solicit the cliquet RouteFactory.

get_record_schema(resource_cls, method)

Return the Cornice schema for the given method.