[Mpuls-commits] r5243 - in base/trunk: . mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 18 18:19:01 CEST 2011


Author: bh
Date: 2011-08-18 18:18:59 +0200 (Thu, 18 Aug 2011)
New Revision: 5243

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case_bundle.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController.markAnonymize): Initialize the variable
total earlier and use it instead of "len(case_bundle.getCases())"
in two places. That expression is horribly inefficient because it
loads each case in the bundle, which includes one database
round-trip for each case, and all that just to count the cases.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-08-18 15:19:53 UTC (rev 5242)
+++ base/trunk/ChangeLog	2011-08-18 16:18:59 UTC (rev 5243)
@@ -1,6 +1,15 @@
 2011-08-18  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/controllers/case_bundle.py
+	(CaseBundleController.markAnonymize): Initialize the variable
+	total earlier and use it instead of "len(case_bundle.getCases())"
+	in two places. That expression is horribly inefficient because it
+	loads each case in the bundle, which includes one database
+	round-trip for each case, and all that just to count the cases.
+
+2011-08-18  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/controllers/case_bundle.py
 	(CaseBundleController.markAnonymize): Fix local variable
 	reference.
 

Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py	2011-08-18 15:19:53 UTC (rev 5242)
+++ base/trunk/mpulsweb/controllers/case_bundle.py	2011-08-18 16:18:59 UTC (rev 5243)
@@ -333,11 +333,12 @@
         confirmed = self._checkBool(confirmed)
         c.context = "../main.mako"
         case_bundle = session.get('casebundle')
+        total = case_bundle.numDatasets()
 
         if not confirmed:
             c.dialog_title = ungettext(u'Clear case for anonymisation?',
                                        u'Clear cases for anonymisation?',
-                                       len(case_bundle.getCases()))
+                                       total)
             c.dialog_text = (
                 ungettext(u"Do you really want to clear the following case for"
                           u" anonymisation? The case will not be available to"
@@ -349,7 +350,7 @@
                           u" you to work on them and they will be presented to"
                           u" the administrators for review for the definite"
                           u" anonymisation.%s",
-                          len(case_bundle.getCases()))
+                          total)
                 % "\n".join(self._buildCaseList(case_bundle)))
             c.url_yes = url_for(controller='/case_bundle',
                                 action='markAnonymize', confirmed=1)
@@ -357,7 +358,6 @@
             return render('/casebundle/dialogs/confirm_anonymize.mako')
 
         successes = case_bundle.markAnonymize()
-        total = case_bundle.numDatasets()
         failures = total - successes
 
         if successes == total:



More information about the Mpuls-commits mailing list