'We also perform access logging in ``process_view()`` since we have the view function,
which tells us the log level. The downside is that we don\'t have the status code,
which isn\'t useful for status logging anyways.'

def process_view(self, request, view_func, view_args, view_kwargs):

    access_log_level = getattr(view_func, 'access_log_level', None)
    if hasattr(view_func, 'login_notrequired'):
        log_page_hit(request, view_func, level=(access_log_level or logging.DEBUG))
        return None
    if (view_func in DJANGO_VIEW_AUTH_WHITELIST):
        log_page_hit(request, view_func, level=(access_log_level or logging.DEBUG))
        return None
    if (request.user.is_active and request.user.is_authenticated()):
        AppSpecificMiddleware.augment_request_with_app(request, view_func)
        try:
            access_view = ('access_view:%s:%s' % (request._desktop_app, resolve(request.path)[0].__name__))
        except Exception as e:
            access_log(request, 'error    checking    view    perm:    %s', e, level=access_log_level)
            access_view = ''
        app_accessed = request._desktop_app
        ui_app_accessed = get_app_name(request)
        if ((app_accessed != ui_app_accessed) and (ui_app_accessed not in ('logs', 'accounts', 'login'))):
            app_accessed = ui_app_accessed
        if (app_accessed and (app_accessed not in ('desktop', 'home', 'home2', 'about', 'hue', 'editor', 'notebook', 'indexer', '404', '500', '403')) and (not (request.user.has_hue_permission(action='access', app=app_accessed) or request.user.has_hue_permission(action=access_view, app=app_accessed)))):
            access_log(request, 'permission    denied', level=access_log_level)
            return PopupException((_('You    do    not    have    permission    to    access    the    %(app_name)s    application.') % {'app_name': app_accessed.capitalize()}), error_code=401).response(request)
        else:
            log_page_hit(request, view_func, level=access_log_level)
            return None
    logging.info('Redirecting    to    login    page:    %s', request.get_full_path())
    access_log(request, 'login    redirection', level=access_log_level)
    if request.ajax:
        response = HttpResponse('/*    login    required    */', content_type='text/javascript')
        response[MIDDLEWARE_HEADER] = 'LOGIN_REQUIRED'
        return response
    else:
        return HttpResponseRedirect(('%s?%s=%s' % (settings.LOGIN_URL, REDIRECT_FIELD_NAME, urlquote(request.get_full_path()))))
