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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 15 11:59:19 CEST 2011


Author: bh
Date: 2011-09-15 11:59:16 +0200 (Thu, 15 Sep 2011)
New Revision: 5342

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
Port helper methods for handling MetaExceptions in the case controller
from WASKU to mpulsweb. The code was taken from WASKU web revision
419:ce88dff87fbb.


Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-09-15 09:37:28 UTC (rev 5341)
+++ base/trunk/mpulsweb/controllers/case.py	2011-09-15 09:59:16 UTC (rev 5342)
@@ -18,6 +18,8 @@
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName, \
      determineAnonymizedCaseEndPhase
 from mpulsweb.lib.db import  PostgresDBInterface
+from mpulsweb.lib.metaclient import MetaException, MetaUnauthorized
+
 from mpulsweb.model.case import ConsistenceCheckException, SessionCase, \
      MPulsXMLImporter, XMLImportException
 from mpulsweb.model.user import UserGroupList, UserListObject
@@ -58,6 +60,38 @@
         return render('/casemanagement/digest_body.mako')
 
     #
+    # helper methods for dealing with meta server related errors.
+    #
+
+    def _meta_error(self, case, exc, title, text, ok_url, template):
+        detail = ""
+        if isinstance(exc, MetaUnauthorized):
+            log.error("Meta server refused request with 401 Unauthorized")
+            detail = _("The meta server did not accept the request"
+                       " because of missing or incorrect username or"
+                       " password. Please check whether the"
+                       " meta-server is configured correctly.")
+
+        elif isinstance(exc, MetaException):
+            # the error parameters should be set already
+            pass
+
+        else:
+            raise RuntimeError("_meta_error not called with MetaException"
+                               " instance")
+
+        if detail:
+            text += "<br>" + detail
+
+        return self._render_error(title, text, ok_url, template)
+
+    def _render_error(self, title, text, ok_url, template):
+        c.dialog_title = title
+        c.dialog_text = text
+        c.url_ok = ok_url
+        return render(template)
+
+    #
     # Delete
     #
 



More information about the Mpuls-commits mailing list