def __call__(self, environ, start_response):
<EOL>if self.template is None or self.status_code == STATUS.NO_CONTENT:<EOL><INDENT>self.content_type = None<EOL>start_response(self.status, self.headerlist)<EOL>if self.template is not None:<EOL><INDENT>self.logger.warn("<STR_LIT>")<EOL><DEDENT>return []<EOL><DEDENT>if not isinstance(self._app_iter, DataCollection) andnot isinstance(self._app_iter, BinaryResponse):<EOL><INDENT>if isinstance(self._app_iter, list):<EOL><INDENT>app_iter_type = "<STR_LIT:list>"<EOL><DEDENT>else:<EOL><INDENT>app_iter_type = self._app_iter.__name__<EOL><DEDENT>msg = "<STR_LIT>" % (<EOL>app_iter_type<EOL>)<EOL>raise TypeError(msg)<EOL><DEDENT>if isinstance(self._app_iter, DataCollection):<EOL><INDENT>if self.attribute_filter is not None:<EOL><INDENT>if not self.attribute_filter.are_any_attributes_visible():<EOL><INDENT>self.logger.warn("<STR_LIT>")<EOL><DEDENT>model_attribute_filter = None<EOL>if isinstance(self._app_iter, Array):<EOL><INDENT>model_attribute_filter = AttributeFilter.from_model(self._app_iter.element_template)<EOL><DEDENT>elif isinstance(self._app_iter, Model):<EOL><INDENT>model_attribute_filter = AttributeFilter.from_model(self._app_iter)<EOL><DEDENT>if model_attribute_filter is not None:<EOL><INDENT>try:<EOL><INDENT>model_attribute_filter.conforms_to_template_filter(self.attribute_filter)<EOL><DEDENT>except exception.AttributeFilterDiffers as exp:<EOL><INDENT>exp.request = self.request<EOL>self.logger.warn("<STR_LIT:%s>" % exp)<EOL><DEDENT><DEDENT><DEDENT>serializable_body = self._app_iter.as_serializable(self.attribute_filter.as_immutable(), self.minify)<EOL>stringified_body = self._selected_serializer.dumps(serializable_body)<EOL>self.content_length = len(stringified_body)<EOL>start_response(self.status, self.headerlist)<EOL>return [stringified_body.encode("<STR_LIT:utf-8>")]<EOL><DEDENT>elif isinstance(self._app_iter, BinaryResponse):<EOL><INDENT>if self._app_iter.content_length == <NUM_LIT:0> orself._app_iter.mime_type is None orself._app_iter.file_name is None:<EOL><INDENT>msg = "<STR_LIT>" % (<EOL>self._app_iter.content_length,<EOL>self._app_iter.mime_type,<EOL>self._app_iter.file_name<EOL>)<EOL>self.logger.warn(msg)<EOL>self.status = STATUS.INTERNAL_SERVER_ERROR<EOL>self.content_type = "<STR_LIT>"<EOL>return []<EOL><DEDENT>self.content_type = self._app_iter.mime_type<EOL>if self._app_iter.as_attachment:<EOL><INDENT>attachment = "<STR_LIT>" % self._app_iter.file_name<EOL>if not isinstance(attachment, str):<EOL><INDENT>attachment = attachment.encode("<STR_LIT>")<EOL><DEDENT>self.headers.add("<STR_LIT>", attachment)<EOL><DEDENT>else:<EOL><INDENT>inline = "<STR_LIT>" % self._app_iter.file_name<EOL>if not isinstance(inline, str):<EOL><INDENT>inline = inline.encode("<STR_LIT>")<EOL><DEDENT>self.headers.add("<STR_LIT>", inline)<EOL><DEDENT>self.content_length = self._app_iter.content_length<EOL>start_response(self.status, self.headerlist)<EOL>return [self._app_iter.contents]<EOL><DEDENT>else:<EOL><INDENT>raise AssertionError("<STR_LIT>")<EOL><DEDENT>
Overridden WSGI application interface