Show
Ignore:
Timestamp:
07/17/08 00:11:51 (5 years ago)
Author:
Nicolas Evrard <nicoe@…>
Branch:
default
Message:

- correctly import StringIO

  • Allow the use of genshi filters on odt templates
    • divided the odt templates in three parts to stop abusing generate
      a Template object, a OOStream object, a OOSerializer object
    • the stream object is responsible for storing the stream of genshi events
      related to content.xml
    • the serializer object knows how to render a stream of event as if it was
      a specific oo file
  • Fixed tests
    • we can now use the events for testing
    • ported test.odt to the new directive syntax
  • The templates and the report are now meant to return genshi streams it is up
    to the framework implementer to call render on them or continue processing
    them.
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • relatorio/reporting.py

    r16 r18  
    1919############################################################################### 
    2020 
    21 __revision__ = "$Id: reporting.py 17 2008-07-15 10:26:58Z nicoe $" 
     21__revision__ = "$Id: reporting.py 19 2008-07-17 00:11:51Z nicoe $" 
    2222__metaclass__ = type 
    2323 
    2424import os, sys 
    2525import warnings 
    26 import cStringIO 
     26from cStringIO import StringIO 
    2727 
    2828import pkg_resources 
     
    104104        self.data_factory = factory 
    105105        self.tmpl_loader = loader 
     106        self.filters = [] 
    106107 
    107108    def __call__(self, obj, **kwargs): 
    108109        template = self.tmpl_loader.load(self.fpath, self.mimetype) 
    109110        data = self.data_factory(obj, **kwargs) 
    110         report = template.generate(**data) 
    111         if not isinstance(report, (cStringIO.InputType, cStringIO.OutputType)): 
    112             report = StringIO(str(report)) 
    113         return report 
     111        return template.generate(**data).filter(*self.filters) 
    114112 
    115113    def __repr__(self):