[Mpuls-commits] r3632 - in base/trunk: . mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 14 20:29:16 CEST 2010


Author: bh
Date: 2010-09-14 20:29:14 +0200 (Tue, 14 Sep 2010)
New Revision: 3632

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCaseList.__nonzero__)
(MpulsCaseList.__len__): New methods to make it easier to
determine how many cases are contained in the case list.
__nonzero__ is defined for backwards compatibility reasons,
because so far, all MpulsCaseList instance were considered True.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-09-14 16:15:34 UTC (rev 3631)
+++ base/trunk/ChangeLog	2010-09-14 18:29:14 UTC (rev 3632)
@@ -1,3 +1,11 @@
+2010-09-14  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/model/case.py (MpulsCaseList.__nonzero__)
+	(MpulsCaseList.__len__): New methods to make it easier to
+	determine how many cases are contained in the case list.
+	__nonzero__ is defined for backwards compatibility reasons,
+	because so far, all MpulsCaseList instance were considered True.
+
 2010-09-14  Roland Geider <roland.geider at intevation.de>
 
 	* mpulsweb/templates/privacy/default/privacy_statement.html:

Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2010-09-14 16:15:34 UTC (rev 3631)
+++ base/trunk/mpulsweb/model/case.py	2010-09-14 18:29:14 UTC (rev 3632)
@@ -298,6 +298,17 @@
     def __init__(self, case_ids=None):
         self.case_list = case_ids or []
 
+    def __nonzero__(self):
+        # for backwards compatibility even empty MpulsCaseList instances
+        # are not considered false.  There's probably no place where an
+        # MpulsCaseList instance is used in a boolean context, though,
+        # so we shouldn't actually need this method and instances where
+        # case_list is empty, should be considered False
+        return True
+
+    def __len__(self):
+        return len(self.case_list)
+
     def listDatasetIds(self):
         return self.case_list
 



More information about the Mpuls-commits mailing list