Show
Ignore:
Timestamp:
01/23/09 02:00:03 (18 months ago)
Author:
Nicolas ?vrard <nicoe@…>
Parents:
100:33521906fedb (diff), 101:fc5e627d5325 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Branch:
default
Message:

Automated merge with ssh://oh/webapps/hg/repos/relatorio

Location:
relatorio/reporting.py
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • relatorio/reporting.py

    r92 r102  
    8484default_loader = MIMETemplateLoader(auto_reload=True) 
    8585 
     86 
    8687class DefaultFactory: 
    8788    """This is the default factory used by relatorio. 
    8889 
    8990    It just returns a copy of the data it receives""" 
     91 
     92    def __init__(self, klass): 
     93        self.working_on = klass 
    9094 
    9195    def __call__(self, **kwargs): 
     
    9498 
    9599default_factory = DefaultFactory() 
     100 
    96101 
    97102class Report: 
     
    150155            data_factory = self.default_factory 
    151156        reports = self.classes.setdefault(klass, ReportDict()) 
    152         report = Report(_absolute(template_path), mimetype, data_factory(), 
     157        report = Report(_absolute(template_path), mimetype, data_factory(klass), 
    153158                        self.loader) 
    154159        reports.ids[report_name] = report, mimetype 
  • relatorio/reporting.py

    r101 r102  
    8282            cls.mime_func.append(id_function) 
    8383 
     84default_loader = MIMETemplateLoader(auto_reload=True) 
     85 
     86 
     87class DefaultFactory: 
     88    """This is the default factory used by relatorio. 
     89 
     90    It just returns a copy of the data it receives""" 
     91 
     92    def __init__(self, klass): 
     93        self.working_on = klass 
     94 
     95    def __call__(self, **kwargs): 
     96        data = kwargs.copy() 
     97        return data 
     98 
     99default_factory = DefaultFactory() 
     100 
    84101 
    85102class Report: 
     
    87104    """ 
    88105 
    89     def __init__(self, path, mimetype, factory, loader): 
     106    def __init__(self, path, mimetype, 
     107                 factory=default_factory, loader=default_loader): 
    90108        self.fpath = path 
    91109        self.mimetype = mimetype 
     
    102120        return '<relatorio report on %s>' % self.fpath 
    103121 
    104  
    105 class DefaultFactory: 
    106     """This is the default factory used by relatorio. 
    107      
    108     It just returns a copy of the data it receives""" 
    109  
    110     def __init__(self, klass): 
    111         self.working_on = klass 
    112  
    113     def __call__(self, **kwargs): 
    114         data = kwargs.copy() 
    115         return data 
    116122 
    117123 
     
    133139        self.classes = {} 
    134140        self.default_factory = datafactory 
    135         self.loader = MIMETemplateLoader(auto_reload=True) 
     141        self.loader = default_loader 
    136142 
    137143    def add_report(self, klass, mimetype, template_path, data_factory=None, 
     
    139145        """adds a report to the repository. 
    140146 
    141         You will be able to find the report via  
     147        You will be able to find the report via 
    142148            - the class it is working on 
    143149            - the mimetype it outputs 
    144150            - the name of the report 
    145          
     151 
    146152        You also have the opportunity to define a specific data_factory. 
    147153        """ 
     
    152158                        self.loader) 
    153159        reports.ids[report_name] = report, mimetype 
    154         reports.mimetypes.setdefault(mimetype, []).append((report, report_name)) 
     160        reports.mimetypes.setdefault(mimetype, []) \ 
     161                         .append((report, report_name)) 
    155162 
    156163    def by_mime(self, klass, mimetype):