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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 15 12:57:04 CEST 2011


Author: bh
Date: 2011-09-15 12:57:04 +0200 (Thu, 15 Sep 2011)
New Revision: 5344

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
Port MetaException handler for CaseController._markForAnonymize from WASKU.
The handler is copied from WASKU web revision 419:ce88dff87fbb.  In
WASKU the handler was in the _do_mark_anonymize_case method, but for the
same reasons as for the handler in _do_delete_case, the handlers are now
in _markForAnonymize: derived classes can more easily override the
exception handler behavior.


Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2011-09-15 10:21:28 UTC (rev 5343)
+++ base/trunk/mpulsweb/controllers/case.py	2011-09-15 10:57:04 UTC (rev 5344)
@@ -18,7 +18,8 @@
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName, \
      determineAnonymizedCaseEndPhase
 from mpulsweb.lib.db import  PostgresDBInterface
-from mpulsweb.lib.metaclient import MetaException, MetaUnauthorized
+from mpulsweb.lib.metaclient import MetaException, MetaUnauthorized, \
+     UnknownMetaCase, UnknownProjectPart, MetaCaseAnonymized, MetaCasePending
 
 from mpulsweb.model.case import ConsistenceCheckException, SessionCase, \
      MPulsXMLImporter, XMLImportException
@@ -234,6 +235,74 @@
         # deletion.
         try:
             return self._do_mark_anonymize_case(case)
+        except (UnknownMetaCase, MetaCaseAnonymized):
+            log.exception("Could not mark case %d for anonymization.", case.id)
+            log.warning("Resetting meta link for case %d.", case.id)
+            case.getMeta().reset()
+            return self._render_error(_("Case document not marked for"
+                                        " anonymization!"),
+                                      _("The case has not been marked for"
+                                        " anonymization because the data could"
+                                        " not be uploaded to the meta server"
+                                        " because the meta case has been"
+                                        " deleted or anonymized."
+                                        " As a result, the link to the"
+                                        " meta-case has been removed."
+                                        " A second attempt to anonymize the"
+                                        " case should succeed."),
+                                      h.url_for(controller="/case_overview"),
+                                      '/casemanagement/dialogs'
+                                      '/failed_markanonymize.mako')
+
+        except UnknownProjectPart:
+            log.exception("Could not mark case %d for anonymization.", case.id)
+            log.warning("Resetting project uuid for case %d.", case.id)
+            case.getMeta().reset_project_uuid()
+            return self._render_error(_("Case document not marked for"
+                                        " anonymization!"),
+                                      _("The case has not been marked for"
+                                        " anonymization because the data could"
+                                        " not be uploaded to the meta server"
+                                        " because the project part does"
+                                        " not exist anymore."
+                                        " The link to project part of the"
+                                        " meta-case has been removed."
+                                        " A second attempt to anonymize the"
+                                        " case should succeed."),
+                                      h.url_for(controller="/case_overview"),
+                                      '/casemanagement/dialogs'
+                                      '/failed_markanonymize.mako')
+
+        except MetaCasePending:
+            log.exception("Could not anonymize case %d.", case.id)
+            return self._render_error(_("Case document not marked for"
+                                        " anonymization!"),
+                                      _("The case has not been marked for"
+                                        " anonymization because the data could"
+                                        " not be uploaded to the meta server"
+                                        " because the meta-case has been"
+                                        " marked for deletion or anonymization."
+                                        " The case may become editable again"
+                                        " later if it is restored on the"
+                                        " meta-server."),
+                                      h.url_for(controller="/case_overview"),
+                                      '/casemanagement/dialogs'
+                                      '/failed_markanonymize.mako')
+
+        except MetaException, exc:
+            log.exception("Could not anonymize case %d because of a problem"
+                          " with the meta server", case.id)
+            return self._meta_error(case, exc,
+                                    _("Case document not marked for"
+                                      " anonymization!"),
+                                    _("The case has not been marked for"
+                                      " anonymization because of an"
+                                      " unexpected problem with the"
+                                      " meta server."),
+                                    h.url_for(controller="/case_overview"),
+                                    '/casemanagement/dialogs'
+                                    '/failed_markanonymize.mako')
+
         except Exception:
             log.exception("Exception while trying to mark case %d for"
                           " anonymisation", case.id)



More information about the Mpuls-commits mailing list