✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ server366.web-hosting.com ​🇻​♯➤ 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 67.223.118.204 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.217.86
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /opt/hc_python/lib/python3.12/site-packages/sentry_sdk/integrations/django//views.py
import functools
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk.consts import OP
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing_utils import has_span_streaming_enabled

if TYPE_CHECKING:
    from typing import Any


try:
    from asyncio import iscoroutinefunction
except ImportError:
    iscoroutinefunction = None  # type: ignore


try:
    from sentry_sdk.integrations.django.asgi import wrap_async_view
except (ImportError, SyntaxError):
    wrap_async_view = None  # type: ignore


def patch_views() -> None:
    from django.core.handlers.base import BaseHandler
    from django.template.response import SimpleTemplateResponse

    from sentry_sdk.integrations.django import DjangoIntegration

    old_make_view_atomic = BaseHandler.make_view_atomic
    old_render = SimpleTemplateResponse.render

    def sentry_patched_render(self: "SimpleTemplateResponse") -> "Any":
        span_streaming = has_span_streaming_enabled(sentry_sdk.get_client().options)
        if span_streaming:
            with sentry_sdk.traces.start_span(
                name="serialize response",
                attributes={
                    "sentry.op": OP.VIEW_RESPONSE_RENDER,
                    "sentry.origin": DjangoIntegration.origin,
                },
            ):
                return old_render(self)
        else:
            with sentry_sdk.start_span(
                op=OP.VIEW_RESPONSE_RENDER,
                name="serialize response",
                origin=DjangoIntegration.origin,
            ):
                return old_render(self)

    @functools.wraps(old_make_view_atomic)
    def sentry_patched_make_view_atomic(
        self: "Any", *args: "Any", **kwargs: "Any"
    ) -> "Any":
        callback = old_make_view_atomic(self, *args, **kwargs)

        # XXX: The wrapper function is created for every request. Find more
        # efficient way to wrap views (or build a cache?)

        integration = sentry_sdk.get_client().get_integration(DjangoIntegration)
        if integration is not None:
            is_async_view = (
                iscoroutinefunction is not None
                and wrap_async_view is not None
                and iscoroutinefunction(callback)
            )
            if is_async_view:
                sentry_wrapped_callback = wrap_async_view(callback)
            else:
                sentry_wrapped_callback = _wrap_sync_view(callback)

        else:
            sentry_wrapped_callback = callback

        return sentry_wrapped_callback

    SimpleTemplateResponse.render = sentry_patched_render
    BaseHandler.make_view_atomic = sentry_patched_make_view_atomic


def _wrap_sync_view(callback: "Any") -> "Any":
    from sentry_sdk.integrations.django import DjangoIntegration

    @functools.wraps(callback)
    def sentry_wrapped_callback(request: "Any", *args: "Any", **kwargs: "Any") -> "Any":
        client = sentry_sdk.get_client()
        span_streaming = has_span_streaming_enabled(client.options)
        current_scope = sentry_sdk.get_current_scope()
        if span_streaming:
            current_span = current_scope.streamed_span
            if type(current_span) is StreamedSpan:
                segment = current_span._segment
                segment._update_active_thread()
        else:
            if current_scope.transaction is not None:
                current_scope.transaction.update_active_thread()

        sentry_scope = sentry_sdk.get_isolation_scope()
        # set the active thread id to the handler thread for sync views
        # this isn't necessary for async views since that runs on main
        if sentry_scope.profile is not None:
            sentry_scope.profile.update_active_thread_id()

        integration = client.get_integration(DjangoIntegration)
        if not integration or not integration.middleware_spans:
            return callback(request, *args, **kwargs)

        if span_streaming:
            with sentry_sdk.traces.start_span(
                name=request.resolver_match.view_name,
                attributes={
                    "sentry.op": OP.VIEW_RENDER,
                    "sentry.origin": DjangoIntegration.origin,
                },
            ):
                return callback(request, *args, **kwargs)
        else:
            with sentry_sdk.start_span(
                op=OP.VIEW_RENDER,
                name=request.resolver_match.view_name,
                origin=DjangoIntegration.origin,
            ):
                return callback(request, *args, **kwargs)

    return sentry_wrapped_callback


Current_dir [ 𝗡𝗢𝗧 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
11 Jun 2026 5.00 AM
root / root
0755
__pycache__
--
11 Jun 2026 5.00 AM
root / root
0755
__init__.py
28.247 KB
11 Jun 2026 5.00 AM
root / root
0644
asgi.py
9.045 KB
11 Jun 2026 5.00 AM
root / root
0644
caching.py
9.367 KB
11 Jun 2026 5.00 AM
root / root
0644
middleware.py
6.404 KB
11 Jun 2026 5.00 AM
root / root
0644
signals_handlers.py
3.711 KB
11 Jun 2026 5.00 AM
root / root
0644
tasks.py
1.579 KB
11 Jun 2026 5.00 AM
root / root
0644
templates.py
6.596 KB
11 Jun 2026 5.00 AM
root / root
0644
transactions.py
4.681 KB
11 Jun 2026 5.00 AM
root / root
0644
views.py
4.463 KB
11 Jun 2026 5.00 AM
root / root
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF