changeset 1067:5bf357a720e7

deprecated setResponseCode method, replaced by emit_http_headers
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 27 Jul 2006 00:27:51 +0200
parents 05e4cd948a0f
children ecece5db5288
files MoinMoin/request/TWISTED.py MoinMoin/request/__init__.py docs/CHANGES
diffstat 3 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/request/TWISTED.py	Thu Jul 27 00:06:18 2006 +0200
+++ b/MoinMoin/request/TWISTED.py	Thu Jul 27 00:27:51 2006 +0200
@@ -112,7 +112,11 @@
 
     def _emit_http_headers(self, headers):
         """ private method to send out preprocessed list of HTTP headers """
-        for header in headers:
+        st_header, other_headers = headers[0], headers[1:]
+        status = st_header.split(':', 1)[1].lstrip()
+        status_code, status_msg = status.split(' ', 1)
+        self.twistd.setResponseCode(status_code, status_message)
+        for header in other_headers:
             key, value = header.split(':', 1)
             value = value.lstrip()
             if key.lower() == 'set-cookie':
@@ -133,6 +137,7 @@
         #self.twistd.finish()
         raise MoinMoinFinish
 
-    def setResponseCode(self, code, message=None):
-        self.twistd.setResponseCode(code, message)
+    #done by _emit_http_headers now:
+    #def setResponseCode(self, code, message=None):
+    #    self.twistd.setResponseCode(code, message)
 
--- a/MoinMoin/request/__init__.py	Thu Jul 27 00:06:18 2006 +0200
+++ b/MoinMoin/request/__init__.py	Thu Jul 27 00:27:51 2006 +0200
@@ -968,13 +968,13 @@
         }
         headers = [
             'Status: %d %s' % (resultcode, statusmsg[resultcode]),
-            'Content-Type: text/plain'
+            'Content-Type: text/plain; charset=utf-8'
         ]
         # when surge protection triggered, tell bots to come back later...
         if resultcode == 503:
             headers.append('Retry-After: %d' % self.cfg.surge_lockout_time)
         self.emit_http_headers(headers)
-        self.setResponseCode(resultcode)
+        #self.setResponseCode(resultcode)
         self.write(msg)
         self.forbidden = True
 
@@ -1196,6 +1196,9 @@
         self.user_headers.append(header)
 
     def setResponseCode(self, code, message=None):
+        """ DEPRECATED, will vanish in moin 1.7,
+            just use a Status: <code> <message> header and emit_http_headers.
+        """
         pass
 
     def fail(self, err):
@@ -1210,7 +1213,7 @@
         """
         self.failed = 1 # save state for self.run()            
         self.emit_http_headers(['Status: 500 MoinMoin Internal Error'])
-        self.setResponseCode(500)
+        #self.setResponseCode(500)
         self.log('%s: %s' % (err.__class__.__name__, str(err)))
         from MoinMoin import failure
         failure.handle(self)
--- a/docs/CHANGES	Thu Jul 27 00:06:18 2006 +0200
+++ b/docs/CHANGES	Thu Jul 27 00:27:51 2006 +0200
@@ -134,6 +134,9 @@
       WSGI ?
       FCGI ?
       TWISTED ?
+    * setResponseCode request method DEPRECATED (it only worked for Twisted
+      anyway), just use emit_http_headers and include a Status: XXX header.
+      Method will vanish with moin 1.7. 
 
   New Features:
     * Removed "underscore in URL" == "blank in pagename magic" - it made more