This file is indexed.

/usr/lib/python3/dist-packages/reversion/middleware.py is in python3-django-reversion 1.10.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Middleware used by Reversion."""

from __future__ import unicode_literals

from django.core.exceptions import ImproperlyConfigured

from reversion.revisions import revision_context_manager


REVISION_MIDDLEWARE_FLAG = "reversion.revision_middleware_active"


class RevisionMiddleware(object):  # pragma: no cover

    """Wraps the entire request in a revision."""

    def process_request(self, request):
        """Starts a new revision."""
        if request.META.get(REVISION_MIDDLEWARE_FLAG, False):
            raise ImproperlyConfigured("RevisionMiddleware can only be included in MIDDLEWARE_CLASSES once.")
        request.META[REVISION_MIDDLEWARE_FLAG] = True
        revision_context_manager.start()

    def _close_revision(self, request):
        """Closes the revision."""
        if request.META.get(REVISION_MIDDLEWARE_FLAG, False):
            del request.META[REVISION_MIDDLEWARE_FLAG]
            revision_context_manager.end()

    def process_response(self, request, response):
        """Closes the revision."""
        # look to see if the session has been accessed before looking for user to stop Vary: Cookie
        if hasattr(request, 'session') and request.session.accessed \
                and hasattr(request, "user") and request.user is not None and request.user.is_authenticated() \
                and revision_context_manager.is_active():
            revision_context_manager.set_user(request.user)
        self._close_revision(request)
        return response

    def process_exception(self, request, exception):
        """Closes the revision."""
        revision_context_manager.invalidate()
        self._close_revision(request)