[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPResponse.py:1.53.8.2 Publish.py:1.155.8.1

Brian Lloyd brian@zope.com
Mon, 15 Apr 2002 16:55:28 -0400


Update of /cvs-repository/Zope/lib/python/ZPublisher
In directory cvs.zope.org:/tmp/cvs-serv6163

Modified Files:
      Tag: Zope-2_5-branch
	HTTPResponse.py Publish.py 
Log Message:
Fixes for hotfix issue.


=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.53.8.1 => 1.53.8.2 ===
         
         return self.__class__(stdout=self.stdout, stderr=self.stderr)
+
+    _shutdown_flag = None
+    def _requestShutdown(self, exitCode=0):
+        """Request that the server shut down with exitCode after fulfilling
+           the current request."""
+        sys.ZServerExitCode = exitCode
+        self._shutdown_flag = 1
+
+    def _shutdownRequested(self):
+        """Returns true if this request requested a server shutdown."""
+        return self._shutdown_flag is not None
     
     def setStatus(self, status, reason=None):
         '''\


=== Zope/lib/python/ZPublisher/Publish.py 1.155 => 1.155.8.1 ===
 
     if must_die:
+        # Try to turn exception value into an exit code.
+        try:
+            if hasattr(must_die[1], 'code'):
+                code = must_die[1].code
+            else: code = int(must_die[1])
+        except:
+            code = must_die[1] and 1 or 0
+        if hasattr(request.response, '_requestShutdown'):
+            request.response._requestShutdown(code)
+
         try: raise must_die[0], must_die[1], must_die[2]
         finally: must_die=None