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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 15 13:13:51 CEST 2011


Author: bh
Date: 2011-09-15 13:13:50 +0200 (Thu, 15 Sep 2011)
New Revision: 5345

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
Port MetaException handlers for CaseController.anonymize from WASKU.
The handlers have been copied from WASKU web revision 419:ce88dff87fbb.
In WASKU the handlers were in the _do_anonymize_case method, but for the
same reasons as for the handler in _do_delete_case, the handlers are now
in anonymize: 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:57:04 UTC (rev 5344)
+++ base/trunk/mpulsweb/controllers/case.py	2011-09-15 11:13:50 UTC (rev 5345)
@@ -384,6 +384,68 @@
 
         try:
             return self._do_anonymize_case(case)
+        except (UnknownMetaCase, MetaCaseAnonymized):
+            log.exception("Could not anonymize case %d.", case.id)
+            log.warning("Resetting meta link for case %d.", case.id)
+            case.getMeta().reset()
+            return self._render_error(_("Case document not anonymized!"),
+                                      _("The case has not been anonymized"
+                                        " because the data could not be"
+                                        " uploaded to the meta server one last"
+                                        " time 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_anonymize.mako')
+        except UnknownProjectPart:
+            log.exception("Could not anonymize case %d.", case.id)
+            log.warning("Resetting project uuid for case %d.", case.id)
+            case.getMeta().reset_project_uuid()
+            return self._render_error(_("Case document not anonymized!"),
+                                      _("The case has not been anonymized"
+                                        " because the data could not be"
+                                        " uploaded to the meta server one last"
+                                        " time 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_anonymize.mako')
+
+        except MetaCasePending:
+            log.exception("Could not anonymize case %d.", case.id)
+            return self._render_error(_("Case document not anonymized!"),
+                                      _("The case has not been anonymized"
+                                        " because the data could not be"
+                                        " uploaded to the meta server one last"
+                                        " time 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_anonymize.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 anonymized!"),
+                                    _("The case can not be anonymized because"
+                                      " of an unexpected problem with the"
+                                      " meta server."),
+                                    h.url_for(controller="/case_overview"),
+                                    '/casemanagement/dialogs'
+                                    '/failed_anonymize.mako')
+
         except Exception:
             log.exception("Exception while trying to anonymize case %s", id)
             c.dialog_title = _("Case document not anonymized!")



More information about the Mpuls-commits mailing list