Ejemplo n.º 1
0
    def generate(self, *args, **kwargs):
        "creates the RelatorioStream."
        serializer = OOSerializer(self._source, self._files)
        kwargs['__relatorio_make_href'] = ImageHref(serializer, kwargs)
        kwargs['__relatorio_make_dimension'] = ImageDimension(self.namespaces)
        kwargs['__relatorio_guess_type'] = self._guess_type
        kwargs['__relatorio_escape_invalid_chars'] = escape_xml_invalid_chars

        counter = ColumnCounter()
        kwargs['__relatorio_reset_col_count'] = counter.reset
        kwargs['__relatorio_inc_col_count'] = counter.inc
        kwargs['__relatorio_store_col_count'] = counter.store

        cache = ExpressionCache()
        kwargs['__relatorio_store_cache'] = cache.store
        kwargs['__relatorio_get_cache'] = cache.get

        stream = super(Template, self).generate(*args, **kwargs)
        if self.has_col_loop:
            # Note that we can't simply add a "number-columns-repeated"
            # attribute and then fill it with the correct number of columns
            # because that wouldn't work if more than one column is repeated.
            transformation = DuplicateColumnHeaders(counter)
            col_filter = Transformer('//repeat[namespace-uri()="%s"]' %
                                     RELATORIO_URI)
            col_filter = col_filter.apply(transformation)
            # Must consume the stream to fill counter
            stream = Stream(list(stream), self.serializer) | col_filter
        return RelatorioStream(stream, serializer)
Ejemplo n.º 2
0
 def generate(self, *args, **kwargs):
     generated = super(Template, self).generate(*args, **kwargs)
     return RelatorioStream(generated, PDFSerializer())