diff options
| -rw-r--r-- | README.rst | 10 | ||||
| -rw-r--r-- | debug_toolbar/middleware.py | 3 | ||||
| -rw-r--r-- | debug_toolbar/panels/profiling.py | 1 | ||||
| -rw-r--r-- | debug_toolbar/utils/__init__.py | 14 | ||||
| -rw-r--r-- | debug_toolbar/utils/tracking/db.py | 4 | ||||
| -rw-r--r-- | example/example.db | bin | 55296 -> 55296 bytes |
6 files changed, 26 insertions, 6 deletions
@@ -180,6 +180,16 @@ output in the shell:: >>> print p.template.name Home +Running the Tests +================= + +The Debug Toolbar includes a limited (and growing) test suite. If you commit code, please consider +adding proper coverage (especially if it has a chance for a regression) in the test suite. + +:: + + python setup.py test + TODOs and BUGS ============== See: https://github.com/django-debug-toolbar/django-debug-toolbar/issues diff --git a/debug_toolbar/middleware.py b/debug_toolbar/middleware.py index af46087..de4ae9c 100644 --- a/debug_toolbar/middleware.py +++ b/debug_toolbar/middleware.py @@ -70,6 +70,7 @@ class DebugToolbarMiddleware(object): return True def process_request(self, request): + __traceback_hide__ = True if self.show_toolbar(request): if self.override_url: original_urlconf = __import__(getattr(request, 'urlconf', settings.ROOT_URLCONF), {}, {}, ['*']) @@ -89,6 +90,7 @@ class DebugToolbarMiddleware(object): self.__class__.debug_toolbars[thread.get_ident()] = toolbar def process_view(self, request, view_func, view_args, view_kwargs): + __traceback_hide__ = True toolbar = self.__class__.debug_toolbars.get(thread.get_ident()) if not toolbar: return @@ -96,6 +98,7 @@ class DebugToolbarMiddleware(object): panel.process_view(request, view_func, view_args, view_kwargs) def process_response(self, request, response): + __traceback_hide__ = True ident = thread.get_ident() toolbar = self.__class__.debug_toolbars.get(ident) if not toolbar: diff --git a/debug_toolbar/panels/profiling.py b/debug_toolbar/panels/profiling.py index 68aafb7..95a1a4d 100644 --- a/debug_toolbar/panels/profiling.py +++ b/debug_toolbar/panels/profiling.py @@ -136,6 +136,7 @@ class ProfilingDebugPanel(DebugPanel): return _('Profiling') def process_view(self, request, view_func, view_args, view_kwargs): + __traceback_hide__ = True self.profiler = cProfile.Profile() args = (request,) + view_args return self.profiler.runcall(view_func, *args, **view_kwargs) diff --git a/debug_toolbar/utils/__init__.py b/debug_toolbar/utils/__init__.py index 61bb717..aa214c9 100644 --- a/debug_toolbar/utils/__init__.py +++ b/debug_toolbar/utils/__init__.py @@ -15,22 +15,28 @@ def ms_from_timedelta(td): """ return (td.seconds * 1000) + (td.microseconds / 1000.0) -def tidy_stacktrace(strace): +def tidy_stacktrace(stack): """ Clean up stacktrace and remove all entries that: 1. Are part of Django (except contrib apps) 2. Are part of SocketServer (used by Django's dev server) 3. Are the last entry (which is part of our stacktracing code) + + ``stack`` should be a list of frame tuples from ``inspect.stack()`` """ trace = [] - for s in strace[:-1]: - s_path = os.path.realpath(s[0]) + for frame, path, line_no, func_name, text in (f[:5] for f in stack): + s_path = os.path.realpath(path) + # Support hiding of frames -- used in various utilities that provide + # inspection. + if '__traceback_hide__' in frame.f_locals: + continue if getattr(settings, 'DEBUG_TOOLBAR_CONFIG', {}).get('HIDE_DJANGO_SQL', True) \ and django_path in s_path and not 'django/contrib' in s_path: continue if socketserver_path in s_path: continue - trace.append((s[0], s[1], s[2], s[3])) + trace.append((path, line_no, func_name, text)) return trace def get_template_info(source, context_lines=3): diff --git a/debug_toolbar/utils/tracking/db.py b/debug_toolbar/utils/tracking/db.py index 87f4550..d1226e4 100644 --- a/debug_toolbar/utils/tracking/db.py +++ b/debug_toolbar/utils/tracking/db.py @@ -1,5 +1,5 @@ +import inspect import sys -import traceback from datetime import datetime @@ -35,7 +35,7 @@ class CursorWrapper(object): finally: stop = datetime.now() duration = ms_from_timedelta(stop - start) - stacktrace = tidy_stacktrace(traceback.extract_stack()) + stacktrace = tidy_stacktrace(inspect.stack()) _params = '' try: _params = simplejson.dumps([force_unicode(x, strings_only=True) for x in params]) diff --git a/example/example.db b/example/example.db Binary files differindex 6eb3916..1339622 100644 --- a/example/example.db +++ b/example/example.db |
