1. Atsushi Odagiri
  2. paste

Commits

ianb  committed 369ea95

When xmlhttp was detected, we weren't saving the debug info, so you couldn't view the full traceback; also the error wasn't very good when a key was missing

  • Participants
  • Parent commits e23232b
  • Branches default

Comments (0)

Files changed (1)

File paste/evalexception/middleware.py

View file
     mochikit.exposed = True
 
     def view(self, environ, start_response):
-        id = int(wsgilib.path_info_pop(environ))
+        id = int(request.path_info_pop(environ))
+        if id not in self.debug_infos:
+            start_response(
+                '500 Server Error',
+                [('Content-type', 'text/html')])
+            return [
+                "Traceback by id %s does not exist (maybe "
+                "the server has been restarted?)"
+                % id]
         debug_info = self.debug_infos[id]
         return debug_info.wsgi_application(environ, start_response)
     view.exposed = True
                                exc_info)
             environ['wsgi.errors'].write('Debug at: %s\n' % view_uri)
 
+            exc_data = collector.collect_exception(*exc_info)
+            debug_info = DebugInfo(count, exc_info, exc_data, base_path,
+                                   environ)
+            assert count not in self.debug_infos
+            self.debug_infos[count] = debug_info
+
             if self.xmlhttp_key:
                 get_vars = wsgilib.parse_querystring(environ)
                 if dict(get_vars).get(self.xmlhttp_key):
                         include_reusable=False, show_extra_data=False)
                     return [html]
 
-            exc_data = collector.collect_exception(*exc_info)
-            debug_info = DebugInfo(count, exc_info, exc_data, base_path,
-                                   environ)
-            assert count not in self.debug_infos
-            self.debug_infos[count] = debug_info
             # @@: it would be nice to deal with bad content types here
             return debug_info.content()