[Zope3-checkins] CVS: Zope3/src/zope/server/http - publisherhttpserver.py:1.4

Jim Fulton jim@zope.com
Thu, 3 Jul 2003 15:37:44 -0400


Update of /cvs-repository/Zope3/src/zope/server/http
In directory cvs.zope.org:/tmp/cvs-serv5616/server/http

Modified Files:
	publisherhttpserver.py 
Log Message:
Added a Post-Mortem debugging HTTP server that enters Python's
post-mortem debugger when an error gets to the publisher.

To use this, copy zope.conf.in to zope.conf and change:


<server>
  type HTTP
  address 8080
</server>

to 

<server>
  type PostmortemDebuggingHTTP
  address 8080
</server>

Do this *after* logging in, so you don't catch Unauthorized errors.



=== Zope3/src/zope/server/http/publisherhttpserver.py 1.3 => 1.4 ===
--- Zope3/src/zope/server/http/publisherhttpserver.py:1.3	Fri Jun  6 15:29:12 2003
+++ Zope3/src/zope/server/http/publisherhttpserver.py	Thu Jul  3 15:37:39 2003
@@ -45,3 +45,24 @@
         response = request.response
         response.setHeaderOutput(task)
         publish(request)
+
+class PMDBHTTPServer(PublisherHTTPServer):
+    """Enter the post-mortem debugger when there's an error
+
+    """
+
+    def executeRequest(self, task):
+        """Overrides HTTPServer.executeRequest()."""
+        env = task.getCGIEnvironment()
+        instream = task.request_data.getBodyStream()
+
+        request = self.request_factory(instream, task, env)
+        response = request.response
+        response.setHeaderOutput(task)
+        try:
+            publish(request, handle_errors=False)
+        except:
+            import sys, pdb
+            pdb.post_mortem(sys.exc_info()[2])
+            raise
+