forked from getsentry/sentry-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
71 lines (45 loc) · 1.52 KB
/
views.py
File metadata and controls
71 lines (45 loc) · 1.52 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from django.contrib.auth import login
from django.contrib.auth.models import User
from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound
from django.shortcuts import render
from django.views.generic import ListView
try:
from rest_framework.decorators import api_view
@api_view(["POST"])
def rest_framework_exc(request):
1 / 0
@api_view(["POST"])
def rest_framework_read_body_and_exc(request):
request.data
1 / 0
except ImportError:
pass
import sentry_sdk
def view_exc(request):
1 / 0
def read_body_and_view_exc(request):
request.read()
1 / 0
def message(request):
sentry_sdk.capture_message("hi")
return HttpResponse("ok")
def mylogin(request):
user = User.objects.create_user("john", "lennon@thebeatles.com", "johnpassword")
user.backend = "django.contrib.auth.backends.ModelBackend"
login(request, user)
return HttpResponse("ok")
def handler500(request):
return HttpResponseServerError("Sentry error: %s" % sentry_sdk.last_event_id())
class ClassBasedView(ListView):
model = None
def head(self, *args, **kwargs):
sentry_sdk.capture_message("hi")
return HttpResponse("")
def post_echo(request):
sentry_sdk.capture_message("hi")
return HttpResponse(request.body)
def handler404(*args, **kwargs):
sentry_sdk.capture_message("not found", level="error")
return HttpResponseNotFound("404")
def template_exc(request, *args, **kwargs):
return render(request, "error.html")