diff options
author | Helmut Grohne <helmut@subdivi.de> | 2008-02-28 02:52:34 +0100 |
---|---|---|
committer | Helmut Grohne <helmut@subdivi.de> | 2008-02-28 02:52:34 +0100 |
commit | aa85b52862c598afab383e777688feb9648cfbf0 (patch) | |
tree | 51e791947291cda33045ca40fb5ece19175fb6d3 | |
parent | 1096a1c1aacf44bf3977fce365f3658b2dd19860 (diff) | |
download | wsgitools-aa85b52862c598afab383e777688feb9648cfbf0.tar.gz |
avoid builtin name filter as variable in wsgitools.filters
-rw-r--r-- | wsgitools/filters.py | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/wsgitools/filters.py b/wsgitools/filters.py index 7f83bd9..2233431 100644 --- a/wsgitools/filters.py +++ b/wsgitools/filters.py @@ -120,41 +120,40 @@ class WSGIFilterMiddleware: def __call__(self, environ, start_response): """wsgi interface""" assert isinstance(environ, dict) - filter = self.filterclass() - environ = filter.filter_environ(environ) + reqfilter = self.filterclass() + environ = reqfilter.filter_environ(environ) def modified_start_response(status, headers, exc_info=None): assert isinstance(status, str) assert isinstance(headers, list) - exc_info = filter.filter_exc_info(exc_info) - status = filter.filter_status(status) - headers = (filter.filter_header(h, v) for h, v in headers) - headers = [h for h in headers if h is not None] - headers = filter.filter_headers(headers) + exc_info = reqfilter.filter_exc_info(exc_info) + status = reqfilter.filter_status(status) + headers = (reqfilter.filter_header(h, v) for h, v in headers) + headers = filter(None, headers) + headers = reqfilter.filter_headers(headers) write = start_response(status, headers, exc_info) def modified_write(data): - write(filter.filter_data(data)) + write(reqfilter.filter_data(data)) return modified_write ret = self.app(environ, modified_start_response) assert hasattr(ret, "__iter__") def modified_close(): - filter.handle_close() + reqfilter.handle_close() getattr(ret, "close", lambda:0)() if isinstance(ret, list): - return CloseableList(modified_close, - [filter.filter_data(data) for data in ret] - + list(filter.append_data())) + return CloseableList(modified_close, map(reqfilter.filter_data, ret) + + list(reqfilter.append_data())) ret = iter(ret) def late_append_data(): - """Invoke filter.append_data() after filter_data() has seen all + """Invoke reqfilter.append_data() after filter_data() has seen all data.""" - for data in filter.append_data(): + for data in reqfilter.append_data(): yield data return CloseableIterator(modified_close, - (filter.filter_data(data) for data in ret), + (reqfilter.filter_data(data) for data in ret), late_append_data()) __all__.append("RequestLogWSGIFilter") |