def frontendediting_request_processor(page, request):
    """
    Sets the frontend editing state in the cookie depending on the
    ``frontend_editing`` GET parameter and the user's permissions.
    """
    if 'frontend_editing' not in request.GET:
        return

    response = HttpResponseRedirect(request.path)

    if request.user.has_module_perms('page'):

        if 'frontend_editing' in request.GET:

            try:
                enable_fe = int(request.GET['frontend_editing']) > 0
            except __HOLE__:
                enable_fe = False

            if enable_fe:
                response.set_cookie(str('frontend_editing'), enable_fe)
                clear_cache()
            else:
                response.delete_cookie(str('frontend_editing'))
                clear_cache()
    else:
        response.delete_cookie(str('frontend_editing'))

    # Redirect to cleanup URLs
    return response
dataset/ETHPy150Open django-leonardo/django-leonardo/leonardo/module/web/processors/edit.py/frontendediting_request_processor