Changeset 102:91c56813903c
- Timestamp:
- 01/23/09 02:00:03 (20 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r92
|
r102
|
|
| 84 | 84 | default_loader = MIMETemplateLoader(auto_reload=True) |
| 85 | 85 | |
| | 86 | |
| 86 | 87 | class DefaultFactory: |
| 87 | 88 | """This is the default factory used by relatorio. |
| 88 | 89 | |
| 89 | 90 | It just returns a copy of the data it receives""" |
| | 91 | |
| | 92 | def __init__(self, klass): |
| | 93 | self.working_on = klass |
| 90 | 94 | |
| 91 | 95 | def __call__(self, **kwargs): |
| … |
… |
|
| 94 | 98 | |
| 95 | 99 | default_factory = DefaultFactory() |
| | 100 | |
| 96 | 101 | |
| 97 | 102 | class Report: |
| … |
… |
|
| 150 | 155 | data_factory = self.default_factory |
| 151 | 156 | 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), |
| 153 | 158 | self.loader) |
| 154 | 159 | reports.ids[report_name] = report, mimetype |
-
|
r101
|
r102
|
|
| 82 | 82 | cls.mime_func.append(id_function) |
| 83 | 83 | |
| | 84 | default_loader = MIMETemplateLoader(auto_reload=True) |
| | 85 | |
| | 86 | |
| | 87 | class 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 | |
| | 99 | default_factory = DefaultFactory() |
| | 100 | |
| 84 | 101 | |
| 85 | 102 | class Report: |
| … |
… |
|
| 87 | 104 | """ |
| 88 | 105 | |
| 89 | | def __init__(self, path, mimetype, factory, loader): |
| | 106 | def __init__(self, path, mimetype, |
| | 107 | factory=default_factory, loader=default_loader): |
| 90 | 108 | self.fpath = path |
| 91 | 109 | self.mimetype = mimetype |
| … |
… |
|
| 102 | 120 | return '<relatorio report on %s>' % self.fpath |
| 103 | 121 | |
| 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 |
| 116 | 122 | |
| 117 | 123 | |
| … |
… |
|
| 133 | 139 | self.classes = {} |
| 134 | 140 | self.default_factory = datafactory |
| 135 | | self.loader = MIMETemplateLoader(auto_reload=True) |
| | 141 | self.loader = default_loader |
| 136 | 142 | |
| 137 | 143 | def add_report(self, klass, mimetype, template_path, data_factory=None, |
| … |
… |
|
| 139 | 145 | """adds a report to the repository. |
| 140 | 146 | |
| 141 | | You will be able to find the report via |
| | 147 | You will be able to find the report via |
| 142 | 148 | - the class it is working on |
| 143 | 149 | - the mimetype it outputs |
| 144 | 150 | - the name of the report |
| 145 | | |
| | 151 | |
| 146 | 152 | You also have the opportunity to define a specific data_factory. |
| 147 | 153 | """ |
| … |
… |
|
| 152 | 158 | self.loader) |
| 153 | 159 | 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)) |
| 155 | 162 | |
| 156 | 163 | def by_mime(self, klass, mimetype): |