[Mpuls-commits] r2697 - in wasko/branches/2.0: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon May 10 19:39:11 CEST 2010


Author: bh
Date: 2010-05-10 19:39:09 +0200 (Mon, 10 May 2010)
New Revision: 2697

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/controllers/case_bundle.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController._downloadXMLExport)
(CaseBundleController._downloadXLSExport)
(CaseBundleController._downloadCSVExport): Removed.  Replaced by
_download_data.
(CaseBundleController._download_data): New.  A parameterized
version of the code in the various _downlooad* methods.
(CaseBundleController.exportAction): Use _download_data for the
actual download.  Also use the same mime types and
content_encoding as in WASKA and WASKO, in particular: use
application/msexcel and no content-encoding for XLS files and
application/xml and UTF-8 for XML.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-05-10 12:34:26 UTC (rev 2696)
+++ wasko/branches/2.0/ChangeLog	2010-05-10 17:39:09 UTC (rev 2697)
@@ -1,5 +1,20 @@
 2010-05-10  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/controllers/case_bundle.py
+	(CaseBundleController._downloadXMLExport)
+	(CaseBundleController._downloadXLSExport)
+	(CaseBundleController._downloadCSVExport): Removed.  Replaced by
+	_download_data.
+	(CaseBundleController._download_data): New.  A parameterized
+	version of the code in the various _downlooad* methods.
+	(CaseBundleController.exportAction): Use _download_data for the
+	actual download.  Also use the same mime types and
+	content_encoding as in WASKA and WASKO, in particular: use
+	application/msexcel and no content-encoding for XLS files and
+	application/xml and UTF-8 for XML.
+
+2010-05-10  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/config/routing.py (make_map): Use the directory
 	containing the python module mpulsweb.controllers as the
 	controllers directory of the base application instead of assuming

Modified: wasko/branches/2.0/mpulsweb/controllers/case_bundle.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case_bundle.py	2010-05-10 12:34:26 UTC (rev 2696)
+++ wasko/branches/2.0/mpulsweb/controllers/case_bundle.py	2010-05-10 17:39:09 UTC (rev 2697)
@@ -515,45 +515,27 @@
         exporttype = form_result.get('exporttype')
         exportanonym = form_result.get('exportanonym')
         exportselection = form_result.get('exportselection')
-        num, export = case_bundle.export(exporttype, 
-                                         exportanonym, 
+        num, export = case_bundle.export(exporttype,
+                                         exportanonym,
                                          exportselection)
         del session['casebundle']
         if exporttype == "XML":
-            return self._downloadXMLExport(export)
+            return self._download_data(export, "application/xml", "xml",
+                                       content_encoding="UTF-8")
         elif exporttype == "XLS":
-            return self._downloadXLSExport(export)
+            return self._download_data(export, "application/msexcel", "xls")
         elif exporttype == "CSV":
-            return self._downloadCSVExport(export)
+            return self._download_data(export, "text/csv", "csv",
+                                       content_encoding='Latin-1')
 
-    def _downloadXMLExport(self, export):
-        data = paste.fileapp.DataApp(
-            export,
-            content_type        = 'text/xml',
-            content_disposition = 'attachment; filename="fallakten-export.xml"',
-            content_encoding    = 'Latin-1',
-            cache_control       = 'must-revalidate',
-            pragma              = 'public')
+    def _download_data(self, data, mime_type, extension, **extra):
+        disposition = 'attachment; filename="fallakten-export.%s"' % extension
+        data = paste.fileapp.DataApp(data,
+                                     content_type=mime_type,
+                                     content_disposition=disposition,
+                                     cache_control='must-revalidate',
+                                     pragma='public',
+                                     **extra)
         return data(request.environ, self.start_response)
 
-    def _downloadXLSExport(self, export):
-        data = paste.fileapp.DataApp(
-            export,
-            content_type        = 'text/msexcel',
-            content_disposition = 'attachment; filename="fallakten-export.xls"',
-            content_encoding    = 'Latin-1',
-            cache_control       = 'must-revalidate',
-            pragma              = 'public')
-        return data(request.environ, self.start_response)
-
-    def _downloadCSVExport(self, export):
-        data = paste.fileapp.DataApp(
-            export,
-            content_type        = 'text/csv',
-            content_disposition = 'attachment; filename="fallakten-export.csv"',
-            content_encoding    = 'Latin-1',
-            cache_control       = 'must-revalidate',
-            pragma              = 'public')
-        return data(request.environ, self.start_response)
-
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:



More information about the Mpuls-commits mailing list