def convertforoutput(self, outputfile): """Convert from one of the source formats into target format. Relevant if converters are used in OutputTemplates. Outputfile is a CLAMOutputFile instance.""" super(CharEncodingConverter, self).convertforoutput(outputfile) return withheaders( flask.make_response((line.encode(self.charset) for line in outputfile)), "text/plain; charset=" + self.charset, )
def convertforoutput(self, outputfile): """Convert from one of the source formats into target format. Relevant if converters are used in OutputTemplates. Outputfile is a CLAMOutputFile instance.""" super(CharEncodingConverter, self).convertforoutput(outputfile) return withheaders( flask.make_response( (line.encode(self.charset) for line in outputfile)), 'text/plain; charset=' + self.charset)
def view(self, file, **kwargs): """Returns the view itself, in xhtml (it's recommended to use flask's template system!). file is a CLAMOutputFile instance. By default, if not overriden and a remote service is specified, this issues a GET to the remote service.""" url = self.url(file) if url: #is the resource external? if self.embed: #fetch if kwargs: req = requests.get(url,data=kwargs) else: req = requests.get(url) return withheaders(flask.make_reponse(req.iter_lines()), self.mimetype) else: #redirect return flask.redirect(url)