django.utils.six.moves.http_client.UNAUTHORIZED

Here are the examples of the python api django.utils.six.moves.http_client.UNAUTHORIZED taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: towel
Source File: api.py
View license
def api_access(minimal):
    """
    Decorator which ensures that the current ``request.access`` model
    provides at least ``minimal`` access.
    """
    def _decorator(func):
        @wraps(func)
        def _fn(request, *args, **kwargs):
            if not request.access:
                return HttpResponse(
                    'No access',
                    status=http_client.UNAUTHORIZED)

            if request.access.access < minimal:
                return HttpResponse(
                    'Insufficient access',
                    status=http_client.UNAUTHORIZED)

            return func(request, *args, **kwargs)
        return _fn
    return _decorator

Example 2

Project: towel
Source File: api.py
View license
def api_access(minimal):
    """
    Decorator which ensures that the current ``request.access`` model
    provides at least ``minimal`` access.
    """
    def _decorator(func):
        @wraps(func)
        def _fn(request, *args, **kwargs):
            if not request.access:
                return HttpResponse(
                    'No access',
                    status=http_client.UNAUTHORIZED)

            if request.access.access < minimal:
                return HttpResponse(
                    'Insufficient access',
                    status=http_client.UNAUTHORIZED)

            return func(request, *args, **kwargs)
        return _fn
    return _decorator