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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Jun 5 17:27:09 CEST 2012


Author: bh
Date: 2012-06-05 17:27:09 +0200 (Tue, 05 Jun 2012)
New Revision: 5974

Modified:
   base/trunk/mpulsweb/controllers/meta.py
Log:
Make the id parameter of the meta/index action optional.

This is a work-around for a problem with the confirm dialog system used
by the meta controller. The URL for the meta/index action is the default
cancel URL used by the dialogs. Since the update to the new routes
version this hasn't worked properly anymore, because routes memory isn't
used anymore and the case ID was not added to the URL, leading to
invalid URLs.

This work-around was already used by the meta/search action. I've added
comments in both places explaining that they're work-arounds and should
be fixed by improving the confirmation dialog system.

Fixes mpuls/issue3163


Modified: base/trunk/mpulsweb/controllers/meta.py
===================================================================
--- base/trunk/mpulsweb/controllers/meta.py	2012-05-29 12:08:21 UTC (rev 5973)
+++ base/trunk/mpulsweb/controllers/meta.py	2012-06-05 15:27:09 UTC (rev 5974)
@@ -60,10 +60,20 @@
 
     '''Controller with meta specific actions.'''
 
-    def index(self, id):
+    def index(self, id=None):
         '''Return a overview page for the meta object. Shows status on
         permission or link. Provides access to varios actions for the meta
         case.'''
+        # FIXME: The id parameter is optional only because the confirm
+        # decorators used on many action of the MetaController cannot
+        # easily add the case id to the default cancel URL, which points
+        # to this index method. As a work-around we use the same
+        # approach as in the search method and make the case id optional
+        # and relying on the case id being present and correct in the
+        # session. A better approach would be to change the dialog
+        # system but that's too much work at the moment.
+        if id is None:
+            id = session.get('case').id
         if id != session.get('meta_caseid'):
             session['meta_caseid'] = id
             session['meta_discretion_statement'] = False
@@ -265,6 +275,10 @@
 
     # Searching and linking meta cases
     def search(self, id=None):
+        # FIXME: the reason (AFAICT) why the id parameter is optional is
+        # that URLs for the search action are passed to the confirm
+        # decorator and therefore cannot be generated with the id. It
+        # would be better to fix the confirm dialog system
         if id is None:
             id = session.get('case').id
         c.case = self._loadCase(id)



More information about the Mpuls-commits mailing list