Get rid of tabs that sneaked into sample code.

This commit is contained in:
Phillip J. Eby 2004-09-18 23:46:50 +00:00
parent 24bd216f0c
commit 110c3a33a3
1 changed files with 27 additions and 27 deletions

View File

@ -253,7 +253,7 @@ server.
# Re-raise original exception if headers sent
raise exc_info[0], exc_info[1], exc_info[2]
finally:
exc_info = None # avoid dangling circular ref
exc_info = None # avoid dangling circular ref
elif headers_sent:
raise AssertionError("Headers already sent!")
@ -263,8 +263,8 @@ server.
result = application(environ, start_response)
try:
for data in result:
if data: # don't send headers until body appears
write(data)
if data: # don't send headers until body appears
write(data)
if not headers_sent:
write('') # send headers now if body was empty
finally:
@ -329,20 +329,20 @@ a block boundary.)
its first non-empty string, so 'transform_ok' has to be a mutable
truth value."""
def __init__(self,result,transform_ok):
if hasattr(result,'close'):
def __init__(self,result,transform_ok):
if hasattr(result,'close'):
self.close = result.close
self._next = iter(result).next
self.transform_ok = transform_ok
def __iter__(self):
return self
def next(self):
if self.transform_ok:
return piglatin(self._next())
else:
return self._next()
def __iter__(self):
return self
def next(self):
if self.transform_ok:
return piglatin(self._next())
else:
return self._next()
class Latinator:
@ -361,28 +361,28 @@ a block boundary.)
for name,value in headers:
if name.lower()=='content-type' and value=='text/plain':
transform_ok.append(True)
# Strip content-length if present, else it'll be wrong
headers = [(name,value)
for name,value in headers
if name.lower()<>'content-length'
]
break
# Strip content-length if present, else it'll be wrong
headers = [(name,value)
for name,value in headers
if name.lower()<>'content-length'
]
break
write = start_response(status,headers,exc_info)
write = start_response(status,headers,exc_info)
if transform_ok:
def write_latin(data):
write(piglatin(data))
return write_latin
def write_latin(data):
write(piglatin(data))
return write_latin
else:
return write
return LatinIter(self.application(environ,start_latin),transform_ok)
# Run foo_app under a Latinator's control, using the example CGI gateway
from foo_app import foo_app
run_with_cgi(Latinator(foo_app))
# Run foo_app under a Latinator's control, using the example CGI gateway
from foo_app import foo_app
run_with_cgi(Latinator(foo_app))
@ -752,7 +752,7 @@ involved. The simplest way to do this is something like::
try:
# do stuff w/exc_info here
finally:
exc_info = None # Avoid circular ref.
exc_info = None # Avoid circular ref.
The example CGI gateway provides another illustration of this
technique.