[Mpuls-commits] r740 - in wasko/branches/1.0: . waskaweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Dec 10 10:10:25 CET 2009


Author: torsten
Date: 2009-12-10 10:10:23 +0100 (Thu, 10 Dec 2009)
New Revision: 740

Modified:
   wasko/branches/1.0/ChangeLog.txt
   wasko/branches/1.0/waskaweb/controllers/evaluate.py
Log:
issue559


Modified: wasko/branches/1.0/ChangeLog.txt
===================================================================
--- wasko/branches/1.0/ChangeLog.txt	2009-12-10 08:00:12 UTC (rev 739)
+++ wasko/branches/1.0/ChangeLog.txt	2009-12-10 09:10:23 UTC (rev 740)
@@ -1,3 +1,10 @@
+2009-12-10 	Torsten Irlaender	<torsten.irlaender at intevation.de> 
+
+	Issue559
+
+	* waskaweb/controllers/evaluate.py: Use dataApp Appliction for
+	returning Attachements.
+
 2009-12-09 	Torsten Irlaender	<torsten.irlaender at intevation.de> 
 
 	Added additonal information on phase in digest

Modified: wasko/branches/1.0/waskaweb/controllers/evaluate.py
===================================================================
--- wasko/branches/1.0/waskaweb/controllers/evaluate.py	2009-12-10 08:00:12 UTC (rev 739)
+++ wasko/branches/1.0/waskaweb/controllers/evaluate.py	2009-12-10 09:10:23 UTC (rev 740)
@@ -3,6 +3,7 @@
 import formencode
 import traceback
 import pylons
+import paste
 import datetime
 
 from pylons import session, g, c
@@ -233,7 +234,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:
@@ -251,7 +253,14 @@
                                 form_result['typelist'])
                 evalset      = EvaluationSet(evalconfig)
                 evalset.evaluate()
-                return evalset.export(EvaluationExportXML())
+                content = evalset.export(EvaluationExportCSV()).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())
@@ -261,7 +270,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:
@@ -279,7 +289,14 @@
                                 form_result['typelist'])
                 evalset      = EvaluationSet(evalconfig)
                 evalset.evaluate()
-                return evalset.export(EvaluationExportCSV())
+                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