[Mpuls-commits] r741 - in waska/trunk: . waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Dec 10 10:14:42 CET 2009
Author: torsten
Date: 2009-12-10 10:14:40 +0100 (Thu, 10 Dec 2009)
New Revision: 741
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/controllers/evaluate.py
Log:
Backported fix for issue559 form wasko
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2009-12-10 09:10:23 UTC (rev 740)
+++ waska/trunk/ChangeLog.txt 2009-12-10 09:14:40 UTC (rev 741)
@@ -1,3 +1,10 @@
+2009-12-10 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Backported patch for issue559 WASKO
+
+ * waskaweb/controllers/evaluate.py: Use dataApp for handling
+ Attachments
+
2009-12-08 Torsten Irlaender <torsten.irlaender at intevation.de>
Set version to 1.6.0
Modified: waska/trunk/waskaweb/controllers/evaluate.py
===================================================================
--- waska/trunk/waskaweb/controllers/evaluate.py 2009-12-10 09:10:23 UTC (rev 740)
+++ waska/trunk/waskaweb/controllers/evaluate.py 2009-12-10 09:14:40 UTC (rev 741)
@@ -3,6 +3,7 @@
import formencode
import traceback
import pylons
+import paste
import datetime
from pylons import session, g, c
@@ -250,7 +251,8 @@
def exportXML(self):
'''Return an XML file containing the result of one or more evaluations.'''
- response.headers['Content-Type'] = 'application/xml; charset=utf8'
+ #Uncommented default way to return file attachments as IE dies not cope with it. Using hackish way with building FileApps
+ #response.headers['Content-Type'] = 'application/xml; charset=utf8'
response.headers['Content-Disposition'] = 'attachment; filename=evaluation-export.xml'
form_result = session.get('evaluation.params')
try:
@@ -268,7 +270,15 @@
form_result['typelist'])
evalset = EvaluationSet(evalconfig)
evalset.evaluate()
- return evalset.export(EvaluationExportXML())
+ # DataApp need string as input
+ content = evalset.export(EvaluationExportXML()).encode('latin1')
+ data = paste.fileapp.DataApp(
+ content,
+ content_type='application/xml',
+ content_encoding='UTF-8',
+ cache_control='must-revalidate',
+ pragma='public')
+ return data(request.environ, self.start_response)
except:
log.error(_('Error: Evaluation failed'))
log.error(traceback.print_exc())
@@ -278,7 +288,8 @@
def exportCSV(self):
'''Return an CSV file containing the result of one or more evaluations.'''
- response.headers['Content-Type'] = 'application/csv; charset=utf8'
+ #Uncommented default way to return file attachments as IE dies not cope with it. Using hackish way with building FileApps
+ #response.headers['Content-Type'] = 'application/xml; charset=utf8'
response.headers['Content-Disposition'] = 'attachment; filename=evaluation-export.csv'
form_result = session.get('evaluation.params')
try:
@@ -296,7 +307,15 @@
form_result['typelist'])
evalset = EvaluationSet(evalconfig)
evalset.evaluate()
- return evalset.export(EvaluationExportCSV())
+ # DataApp need string as input
+ content = evalset.export(EvaluationExportCSV()).encode('latin1')
+ data = paste.fileapp.DataApp(
+ content,
+ content_type='application/csv',
+ content_encoding='UTF-8',
+ cache_control='must-revalidate',
+ pragma='public')
+ return data(request.environ, self.start_response)
except:
log.error(_('Error: Evaluation failed'))
log.error(traceback.print_exc())
More information about the Mpuls-commits
mailing list