[Mpuls-commits] r5368 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 16 17:06:08 CEST 2011


Author: torsten
Date: 2011-09-16 17:06:07 +0200 (Fri, 16 Sep 2011)
New Revision: 5368

Modified:
   base/trunk/mpulsweb/controllers/meta.py
Log:
Modify controller method "digest" to fetch a list of participating agencies.


Modified: base/trunk/mpulsweb/controllers/meta.py
===================================================================
--- base/trunk/mpulsweb/controllers/meta.py	2011-09-16 14:58:50 UTC (rev 5367)
+++ base/trunk/mpulsweb/controllers/meta.py	2011-09-16 15:06:07 UTC (rev 5368)
@@ -354,32 +354,35 @@
             return self._handle_meta_exception(meta, exc, "push",
                                                _('Error! Data not uploaded.'))
 
-    def strip_meta(self, meta, sneedle, eneedle):
+    def strip_meta(self, html, sneedle, eneedle):
         '''Strips specific part from meta case html. Start and End of part is
         defined by the search of sneedle and eneedle'''
-        try:
-            raw = meta.pull()
-            start = raw.find(sneedle)
-            end = raw.find(eneedle) + len(eneedle)
-            c.metacase = unicode(raw[start:end], 'utf-8')
-            return render(url_for('/meta/case.mako'))
-        except MetaException, exc:
-            return self._handle_meta_exception(meta, exc, "pull",
-                                               _('Error! Data not downloaded.'))
+        start = html.find(sneedle)
+        end = html.find(eneedle) + len(eneedle)
+        c.metacase = unicode(html[start:end], 'utf-8')
+        return render(url_for('/meta/case.mako'))
 
     def digest(self, id):
         '''Will return the digest part of the meta case html'''
         meta = self._loadCase(id).getMeta()
-        sneedle = "<!-- START CASE DIGEST -->"
-        eneedle = "<!-- END CASE DIGEST -->"
-        return self.strip_meta(meta, sneedle, eneedle)
+        sneedle = "<!-- START CASE BODY -->"
+        eneedle = "<!-- END CASE BODY -->"
+        try:
+            return self.strip_meta(meta.agencies(), sneedle, eneedle)
+        except MetaException, exc:
+            return self._handle_meta_exception(meta, exc, "digest",
+                                               _('Error! Data not downloaded.'))
 
     def download(self, id):
         '''Will return the body the full meta case html'''
         meta = self._loadCase(id).getMeta()
         sneedle = "<!-- START CASE BODY -->"
         eneedle = "<!-- END CASE BODY -->"
-        return self.strip_meta(meta, sneedle, eneedle)
+        try:
+            return self.strip_meta(meta.pull(), sneedle, eneedle)
+        except MetaException, exc:
+            return self._handle_meta_exception(meta, exc, "pull",
+                                               _('Error! Data not downloaded.'))
 
     def _handle_meta_exception(self, meta, exc, action_name, title):
         log.exception("Exception during action %(action)r for"



More information about the Mpuls-commits mailing list