def __call__(self, environ, start_response): if self.__detect_flex(environ) \ and environ['REQUEST_METHOD'] == 'GET' \ and environ.get('HTTP_ACCEPT'): # Override the Accept header. We prefer ATOM, but also allow # the server to decide if ATOM is not available. environ['HTTP_ACCEPT'] = \ "%s;q=0.9,*/*;q=0.8" % AtomMime.mime_type_string return Filter.__call__(self, environ, start_response)
def filter_output(self, environ, start_response, status, headers, app_iter): if self.__detect_flex(environ): # All the fuzz is just for Flex/Flash clients. # Wrap start response to pass HTTP OK back to Flash. Also, we # need to have access to the status later. environ['flexfilter.status'] = status wrap_start_response = \ lambda status, headers: start_response(HTTPOk().status, headers) return Filter.filter_output(self, environ, wrap_start_response, status, headers, app_iter) else: #unfiltered response for non flash clients start_response(status, headers) return app_iter