[Mpuls-commits] r5333 - base/trunk/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 14 18:55:48 CEST 2011


Author: bh
Date: 2011-09-14 18:55:47 +0200 (Wed, 14 Sep 2011)
New Revision: 5333

Modified:
   base/trunk/mpulsweb/model/case.py
Log:
Port Case model methods getHashFields and is_hashable from WASKU to
mpulsweb. The getHashFields method is only a stub here which always
raises NotImplementedError, because it cannot be implemented fully in
mpulsweb as it doesn't know how to extract the needed information from
the case. The is_hashable method is copied unchanged from WASKU web
412:2988cbbf9f39, though.


Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2011-09-14 16:28:00 UTC (rev 5332)
+++ base/trunk/mpulsweb/model/case.py	2011-09-14 16:55:47 UTC (rev 5333)
@@ -1074,8 +1074,32 @@
                 db.recycleConnection(conn, cur)
         except:
             log.exception(_('Error on fetching data for formletter'))
-        return fields, order 
+        return fields, order
 
+    def getHashFields(self):
+        """Return a dictionary of fields to be used for the meta case hashvalue.
+
+        The dictionary should contain the following keys: firstname,
+        birthname, gender and birthdate. firstname and birthname are
+        strings, birthdate is a date object and gender should be an int
+        with 0 meaning 'female', 1 meaning male and -1 for the case
+        where the gender hasn't been set yet.
+
+        This default implementation always raises NotImplemented.
+        mpuls-Applications should override this method if they need
+        support for the meta-server.
+        """
+        raise NotImplementedError
+
+    def is_hashable(self):
+        """Returns a true if the case has all information to build a hash."""
+        fields = self.getHashFields()
+        for k, f in fields.iteritems():
+            if f in [-1, "", None]:
+                return False
+        return True
+
+
 class SessionCase:
 
     """This class holds all needed information for the currently selected case



More information about the Mpuls-commits mailing list