[Zope-Checkins] CVS: Zope/lib/python/ZPublisher - HTTPResponse.py:1.65

Tres Seaver tseaver@zope.com
Sat, 22 Jun 2002 11:34:39 -0400


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

Modified Files:
	HTTPResponse.py 
Log Message:
 - Whitespace normalization

=== Zope/lib/python/ZPublisher/HTTPResponse.py 1.64 => 1.65 === (457/557 lines abridged)
 
 $Id$'''
-__version__='$Revision$'[11:-2]
+__version__ = '$Revision$'[11:-2]
 
 import types, os, sys, re
 import zlib, struct
@@ -23,7 +23,7 @@
 from zExceptions import Unauthorized
 from zExceptions.ExceptionFormatter import format_exception
 
-nl2sp=maketrans('\n',' ')
+nl2sp = maketrans('\n',' ')
 
 
 # Enable APPEND_TRACEBACKS to make Zope append tracebacks like it used to,
@@ -31,7 +31,7 @@
 APPEND_TRACEBACKS = 0
 
 
-status_reasons={
+status_reasons = {
 100: 'Continue',
 101: 'Switching Protocols',
 102: 'Processing',
@@ -80,25 +80,25 @@
 507: 'Insufficient Storage',
 }
 
-status_codes={}
+status_codes = {}
 # Add mappings for builtin exceptions and
 # provide text -> error code lookups.
 for key, val in status_reasons.items():
-    status_codes[''.join(val.split(' ')).lower()]=key
-    status_codes[val.lower()]=key
-    status_codes[key]=key
-    status_codes[str(key)]=key
-en=filter(lambda n: n[-5:]=='Error', dir(__builtins__))
+    status_codes[''.join(val.split(' ')).lower()] = key
+    status_codes[val.lower()] = key
+    status_codes[key] = key
+    status_codes[str(key)] = key
+en = filter(lambda n: n[-5:] == 'Error', dir(__builtins__))
 for name in en:
-    status_codes[name.lower()]=500
-status_codes['nameerror']=503
-status_codes['keyerror']=503
-status_codes['redirect']=300
+    status_codes[name.lower()] = 500

[-=- -=- -=- 457 lines omitted -=- -=- -=-]

+            str_rep = str(content_length)
+            if str_rep[-1:] == 'L':
+                str_rep = str_rep[:-1]
                 self.setHeader('content-length', str_rep)
 
-        headersl=[]
-        append=headersl.append
+        headersl = []
+        append = headersl.append
 
         # status header must come first.
         append("Status: %s" % headers.get('status', '200 OK'))
@@ -780,19 +807,19 @@
         if headers.has_key('status'):
             del headers['status']
         for key, val in headers.items():
-            if key.lower()==key:
+            if key.lower() == key:
                 # only change non-literal header names
-                key="%s%s" % (key[:1].upper(), key[1:])
-                start=0
-                l=key.find('-',start)
+                key = "%s%s" % (key[:1].upper(), key[1:])
+                start = 0
+                l = key.find('-',start)
                 while l >= start:
-                    key="%s-%s%s" % (key[:l],key[l+1:l+2].upper(),key[l+2:])
-                    start=l+1
-                    l=key.find('-',start)
+                    key = "%s-%s%s" % (key[:l],key[l+1:l+2].upper(),key[l+2:])
+                    start = l + 1
+                    l = key.find('-', start)
             append("%s: %s" % (key, val))
         if self.cookies:
-            headersl=headersl+self._cookie_list()
-        headersl[len(headersl):]=[self.accumulated_headers, body]
+            headersl = headersl+self._cookie_list()
+        headersl[len(headersl):] = [self.accumulated_headers, body]
         return '\n'.join(headersl)
 
     def write(self,data):
@@ -812,7 +839,7 @@
         """
         if not self._wrote:
             self.outputBody()
-            self._wrote=1
+            self._wrote = 1
             self.stdout.flush()
 
         self.stdout.write(data)