Skip to content

Commit e455bec

Browse files
committed
fixed AttributeError on 404 page exception in ProfilerPanel.process_response
1 parent 0e262ae commit e455bec

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

debug_toolbar/middleware.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ def _show_toolbar(self, request):
7474
def process_request(self, request):
7575
__traceback_hide__ = True
7676
if self.show_toolbar(request):
77-
7877
urlconf = getattr(request, 'urlconf', settings.ROOT_URLCONF)
7978
if isinstance(urlconf, basestring):
8079
urlconf = import_module(getattr(request, 'urlconf', settings.ROOT_URLCONF))

debug_toolbar/panels/profiling.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def _unwrap_closure_and_profile(self, func):
163163
self._unwrap_closure_and_profile(cell.cell_contents)
164164

165165
def process_view(self, request, view_func, view_args, view_kwargs):
166-
print "process_view", view_func
166+
__traceback_hide__ = True
167167
self.profiler = cProfile.Profile()
168168
args = (request,) + view_args
169169
if DJ_PROFILE_USE_LINE_PROFILER:
@@ -189,6 +189,9 @@ def add_node(self, func_list, func, max_depth, cum_time=0.1):
189189
self.add_node(func_list, subfunc, max_depth, cum_time=cum_time)
190190

191191
def process_response(self, request, response):
192+
__traceback_hide__ = True
193+
if not hasattr(self, 'profiler'):
194+
return None
192195
self.profiler.create_stats()
193196
self.stats = DjangoDebugToolbarStats(self.profiler)
194197
if DJ_PROFILE_USE_LINE_PROFILER:

example/example.db

0 Bytes
Binary file not shown.

example/settings.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,41 @@
5151

5252
CACHE_BACKEND = 'dummy://'
5353
#CACHE_BACKEND = 'memcached://127.0.0.1:11211'
54+
LOGGING = {
55+
'version': 1,
56+
'disable_existing_loggers': True,
57+
'formatters': {
58+
'verbose': {
59+
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
60+
},
61+
},
62+
'handlers': {
63+
'null': {
64+
'level':'DEBUG',
65+
'class':'django.utils.log.NullHandler',
66+
},
67+
'console':{
68+
'level':'DEBUG',
69+
'class':'logging.StreamHandler',
70+
'formatter': 'verbose'
71+
},
72+
},
73+
'loggers': {
74+
'django': {
75+
'handlers':['null'],
76+
'propagate': True,
77+
'level':'INFO',
78+
},
79+
'django.request': {
80+
'handlers': ['console'],
81+
'level': 'ERROR',
82+
'propagate': False,
83+
},
84+
'django.db.backends': {
85+
'handlers': ['console'],
86+
'level': 'DEBUG',
87+
'propagate': False,
88+
},
89+
}
90+
}
5491

0 commit comments

Comments
 (0)