[Mpuls-commits] r621 - in wasko/branches/1.0: . waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Oct 6 10:54:04 CEST 2009
Author: torsten
Date: 2009-10-06 10:54:03 +0200 (Tue, 06 Oct 2009)
New Revision: 621
Modified:
wasko/branches/1.0/ChangeLog.txt
wasko/branches/1.0/waskaweb/controllers/evaluate.py
Log:
Added XML and CSV Export
Modified: wasko/branches/1.0/ChangeLog.txt
===================================================================
--- wasko/branches/1.0/ChangeLog.txt 2009-10-06 08:33:35 UTC (rev 620)
+++ wasko/branches/1.0/ChangeLog.txt 2009-10-06 08:54:03 UTC (rev 621)
@@ -18,6 +18,11 @@
waskaweb/templates/evaluation/evaluate.mako: Display result of the
evaluation in a new window. Created new styles.
+ Added XML and CSV Export
+
+ * waskaweb/controllers/evaluate.py: Added controllers for XML and CSV
+ Export.
+
2009-10-05 Torsten Irlaender <torsten.irlaender at intevation.de>
Fixed logbuch evalauation
Modified: wasko/branches/1.0/waskaweb/controllers/evaluate.py
===================================================================
--- wasko/branches/1.0/waskaweb/controllers/evaluate.py 2009-10-06 08:33:35 UTC (rev 620)
+++ wasko/branches/1.0/waskaweb/controllers/evaluate.py 2009-10-06 08:54:03 UTC (rev 621)
@@ -102,6 +102,7 @@
def _get_evalparams(self, form_result):
params = {}
+ params['id'] = form_result['id']
params['start_date'] = str(form_result['start_date'])
params['end_date'] = str(form_result['end_date'])
params['typelist'] = form_result['typelist']
@@ -202,7 +203,7 @@
evalset = EvaluationSet(evalconfig, True)
evalset.evaluate()
c.result = evalset.export(EvaluationExportHTML(show_percent=form_result['show_percent']))
- session['evaluation.params'] = form_result
+ session['evaluation.params'] = eval_params
session.save()
form = render('/evaluation/result.mako')
return formencode.htmlfill.render(unicode(form, 'utf-8'), \
@@ -214,3 +215,58 @@
log.error(traceback.print_exc())
finally:
db.recycleConnection(conn, cur)
+
+ def exportXML(self):
+ '''Return an XML file containing the result of one or more evaluations.'''
+ 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.error(_('Error: Evaluation failed'))
+ log.error(traceback.print_exc())
+ finally:
+ db.recycleConnection(conn, cur)
+
+
+ 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'
+ 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(EvaluationExportCSV())
+ except:
+ log.error(_('Error: Evaluation failed'))
+ log.error(traceback.print_exc())
+ finally:
+ db.recycleConnection(conn, cur)
More information about the Mpuls-commits
mailing list