Ticket #4786: views_debug_py.3.diff
File views_debug_py.3.diff, 2.4 KB (added by , 16 years ago) |
---|
-
django/views/debug.py
8 8 from django.utils.html import escape 9 9 from django.http import HttpResponse, HttpResponseServerError, HttpResponseNotFound 10 10 from django.utils.encoding import smart_unicode 11 from django.db.models.loading import get_apps 11 12 12 13 HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD|PROFANITIES_LIST') 13 14 … … 186 187 post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]] 187 188 188 189 return lower_bound, pre_context, context_line, post_context 190 191 def _is_installed_app_file(self, app_module_paths, filename): 192 for path in app_module_paths: 193 if filename.startswith(path): 194 return True 195 return False 189 196 190 197 def get_traceback_frames(self): 191 198 frames = [] 192 199 tb = self.tb 200 app_module_paths = [os.path.normpath(os.path.dirname(mod.__file__)) 201 for mod in get_apps() 202 if not mod.__name__.startswith('django.')] 203 193 204 while tb is not None: 194 205 # support for __traceback_hide__ which is used by a few libraries 195 206 # to hide internal frames. … … 207 218 'tb': tb, 208 219 'filename': filename, 209 220 'function': function, 221 'app_code': self._is_installed_app_file(app_module_paths, filename), 210 222 'lineno': lineno + 1, 211 223 'vars': tb.tb_frame.f_locals.items(), 212 224 'id': id(tb), … … 313 325 div.context ol.context-line li span { float: right; } 314 326 div.commands { margin-left: 40px; } 315 327 div.commands a { color:black; text-decoration:none; } 328 code.app-code { font-weight: bold; } 316 329 #summary { background: #ffc; } 317 330 #summary h2 { font-weight: normal; color: #666; } 318 331 #explanation { background:#eee; } … … 477 490 <ul class="traceback"> 478 491 {% for frame in frames %} 479 492 <li class="frame"> 480 <code >{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code>493 <code{% if frame.app_code %} class="app-code" {% endif %}>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code> 481 494 482 495 {% if frame.context_line %} 483 496 <div class="context" id="c{{ frame.id }}">