Api

1
from Digitalblend.iControl import apis
class Digitalblend.iControl.apis.Api

Encapsulate all api options and functionality for a given model.

static register(model, route)

Register the given model with the given api route class.

Parameters
  • model (Model) – The model class to link with route api.

  • route (Route) – The admin class to register.

1
apis.Api.register(ExampleModel, ExampleRoute)
class Digitalblend.iControl.apis.Route(**kwargs)

A route that provide read-only actions. List or Get.

endpoint()

Used to mark a method from a Route that correspond to a downloadable field (FileField).

1
2
3
@apis.Route.detail
def fileFieldName(self, request, pk=None):
    return self.sendFile(self.get_object().fileFieldName)
property serializer_class
Type

Serializer

The linked serializer class.

1
serializer_class = ExampleSerializer

Note

Must be implemented.

class Digitalblend.iControl.apis.Permission

Permission checks are always run at the very start of the view, before any other code is allowed to proceed. Permission checks will typically use the authentication information in the request.user and request.auth properties to determine if the incoming request should be permitted.

Override this inner class in your Routes to provides per object permissions.

1
2
3
4
5
6
class Permission(apis.Permission):
    def has_object_permission(self, request, view, obj):
        if request.user.levelprofile.level in obj.levels.all():
            return True
        else:
            return False
Defaults = <module 'rest_framework.permissions' from '/Users/guillaume/Workspace/Digitalblend/Framework/iControlServer-python/.env/lib/python3.5/site-packages/rest_framework/permissions.py'>

A set of permissions.

  • AllowAny

  • IsAuthenticated

  • IsAdminUser

1
permission_classes = (apis.Permission.Defaults.IsAuthenticated, Permission, )