[Mpuls-commits] r3921 - in base/trunk: . mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Oct 7 16:35:04 CEST 2010
Author: bh
Date: 2010-10-07 16:35:03 +0200 (Thu, 07 Oct 2010)
New Revision: 3921
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/controllers/evaluate.py
Log:
* mpulsweb/controllers/evaluate.py
(EvaluateController._do_export): New method containing the code
shared by exportCSV and exportXML.
(EvaluateController.exportXML, EvaluateController.exportCSV): Use
_do_export for the actual evaluation and export.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-10-07 14:18:26 UTC (rev 3920)
+++ base/trunk/ChangeLog 2010-10-07 14:35:03 UTC (rev 3921)
@@ -1,5 +1,13 @@
2010-10-07 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/controllers/evaluate.py
+ (EvaluateController._do_export): New method containing the code
+ shared by exportCSV and exportXML.
+ (EvaluateController.exportXML, EvaluateController.exportCSV): Use
+ _do_export for the actual evaluation and export.
+
+2010-10-07 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/controllers/evaluate.py: Remove unused imports.
Reorder imports according to convention.
Modified: base/trunk/mpulsweb/controllers/evaluate.py
===================================================================
--- base/trunk/mpulsweb/controllers/evaluate.py 2010-10-07 14:18:26 UTC (rev 3920)
+++ base/trunk/mpulsweb/controllers/evaluate.py 2010-10-07 14:35:03 UTC (rev 3921)
@@ -258,38 +258,22 @@
response.headers['Content-Type'] = 'application/xml; charset=utf8'
response.headers['Content-Disposition'] = \
'attachment; filename=evaluation-export.xml'
- form_result = session.get('evaluation.params')
- try:
- try:
- conn, cur = db.getConnection(), None
- evalconfig = EvaluationConfig(get_configfile(form_result['id']),
- conn,
- form_result['start_date'],
- form_result['end_date'],
- form_result['start_date_field'],
- form_result['end_date_field'],
- None,
- form_result['sql'],
- form_result['typelist'])
- evalset = EvaluationSet(evalconfig)
- evalset.evaluate()
- return evalset.export(EvaluationExportXML())
- except:
- log.exception(_('XML Export failed'))
- finally:
- db.recycleConnection(conn, cur)
+ return self._do_export(EvaluationExportXML)
-
def exportCSV(self):
'''Return an CSV file containing the result of one or more evaluations.
'''
response.headers['Content-Type'] = 'application/csv; charset=utf8'
response.headers['Content-Disposition'] = \
'attachment; filename=evaluation-export.csv'
+ return self._do_export(EvaluationExportCSV)
+
+ def _do_export(self, export_class):
form_result = session.get('evaluation.params')
try:
try:
- conn, cur = db.getConnection(), None
+ conn = db.getConnection()
+ cur = None
evalconfig = EvaluationConfig(get_configfile(form_result['id']),
conn,
form_result['start_date'],
@@ -301,8 +285,8 @@
form_result['typelist'])
evalset = EvaluationSet(evalconfig)
evalset.evaluate()
- return evalset.export(EvaluationExportCSV())
+ return evalset.export(export_class())
except:
- log.exception(_('CSV Export failed'))
+ log.exception("Export with %r failed", export_class)
finally:
db.recycleConnection(conn, cur)
More information about the Mpuls-commits
mailing list