def METHOD_NAME(view_function):
    """
    Decorator for django_cradmin views.
    Protects the view, making it impossible to access unless the requesting user
    has the role defined by the named url variable ``roleid``.
    Adds the following variables to the request:
        - ``cradmin_role``: The detected cradmin role. This is ``None``
            if the ``roleclass`` attribute of the cradmin instance is ``None``.
    """
    @wraps(view_function)
    def wrapper(request, *args, **kwargs):
        if request.cradmin_instance.roleclass:
            roleid = kwargs.pop('roleid')
            role = request.cradmin_instance.get_role_from_roleid(roleid)
            if not role:
                return request.cradmin_instance.invalid_roleid_response(roleid)
            try:
                role_from_rolequeryset = request.cradmin_instance.get_role_from_rolequeryset(role)
            except ObjectDoesNotExist:
                response = request.cradmin_instance.missing_role_response(role)
            else:
                request.cradmin_role = role_from_rolequeryset
                response = view_function(request, *args, **kwargs)
        else:
            request.cradmin_role = None
            response = view_function(request, *args, **kwargs)
        if isinstance(response, HttpResponse):
            http_headers = request.cradmin_instance.get_common_http_headers()
            if http_headers:
                for headerattribute, headervalue in http_headers.items():
                    response[headerattribute] = headervalue
        request.cradmin_instance.add_extra_instance_variables_to_request(request)
        return response
    return wrapper