<commit_before>from django.http import Http404
from django.shortcuts import get_object_or_404

from feincms.module.page import processors
from feincms.module.page.models import Page
from feincms.views.base import Handler


class PreviewHandler(Handler):
    """
    Preview handler

    The methods used in this handler should not be considered official API.

    *** Everything here is subject to change. ***
    """

    def __call__(self, request, path, page_id):
        if not request.user.is_staff:
            raise Http404

        page = get_object_or_404(Page, pk=page_id)

        # Throw out request processor which will cause the page to-be-previewed
        # to be seen as inactive (which is the case, of course)
        page.request_processors = [rp for rp in Page.request_processors if rp not in (
            processors.require_path_active_request_processor,)]

        # Remove _preview/42/ from URL, the rest of the handler code should not
        # know that anything about previewing. Handler.prepare will still raise
        # a 404 if the extra_path isn't consumed by any content type
        request.path = page.get_absolute_url()

        response = self.build_response(request, page)
        response['Cache-Control'] = 'no-cache, must-revalidate, no-store, private'<commit_msg>The processors module does not exist (yet)<commit_after>from django.http import Http404
from django.shortcuts import get_object_or_404

from feincms.module.page.models import Page
from feincms.views.base import Handler


class PreviewHandler(Handler):
    """
    Preview handler

    The methods used in this handler should not be considered official API.

    *** Everything here is subject to change. ***
    """

    def __call__(self, request, path, page_id):
        if not request.user.is_staff:
            raise Http404

        page = get_object_or_404(Page, pk=page_id)

        # Throw out request processor which will cause the page to-be-previewed
        # to be seen as inactive (which is the case, of course)
        page.request_processors = [rp for rp in Page.request_processors if rp not in (
            Page.require_path_active_request_processor,)]

        # Remove _preview/42/ from URL, the rest of the handler code should not
        # know that anything about previewing. Handler.prepare will still raise
        # a 404 if the extra_path isn't consumed by any content type
        request.path = page.get_absolute_url()

        response = self.build_response(request, page)
        response['Cache-Control'] = 'no-cache, must-revalidate, no-store, private'
{'fraction_non_alphanumeric': 0.07104247104247104, 'fraction_numerical': 0.013127413127413128, 'mean_word_length': 3.0675039246467817, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5979560', 'n_tokens_mistral': 748, 'n_tokens_neox': 691, 'n_words': 259}