-
Notifications
You must be signed in to change notification settings - Fork 580
Description
Django 2.2.16
Sentry 0.16.4+
When using sentry 0.16.4+, the resolver has been patched to return phony view functions that wrap calling the actual view function. This breaks anything that uses the resolver matched view function to compare to an imported function, eg we have middleware acting as a guardian with code like this:
@custom_login_required_decorator
def the_view(request):
request.session["skip"] = 1
return redirect(reverse("homepage"))
def can_skip(request):
return "skip" in request.session
class Guardian:
def process_view(self, request, view_func, view_args, view_kwargs):
if can_skip(request) or view_func == the_view:
return
return redirect(reverse("the_view"))With sentry 0.16.3 (and every version of sentry-sdk before that, and with raven...), this worked fine. With sentry 0.16.4+, the view_func has been replaced. I'm pretty sure that 193f591 is responsible (and this is by design...). If this is the only way of achieving the functionality you need from the views, then at the very least this deficiency needs to be documented prominently - here perhaps
With sentry 0.17.8 enabled:
(Pdb) p view_func
<function set_client_code at 0x7fc81f1c26a8>
(Pdb) p set_client_code
<portal.utils.login_utils._ExtendedCheckLogin object at 0x7fc8210b54a8>
With sentry 0.17.8, but disabled:
(Pdb) p view_func
<portal.utils.login_utils._ExtendedCheckLogin object at 0x7fc63afbb128>
(Pdb) p set_client_code
<portal.utils.login_utils._ExtendedCheckLogin object at 0x7fc63afbb128>
With sentry 0.16.3 enabled:
(Pdb) p view_func
<portal.utils.login_utils._ExtendedCheckLogin object at 0x7f3324e504a8>
(Pdb) p set_client_code
<portal.utils.login_utils._ExtendedCheckLogin object at 0x7f3324e504a8>