[Mpuls-commits] r977 - in wasko/branches/2.0: . waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 28 12:12:44 CET 2010


Author: bh
Date: 2010-01-28 12:12:38 +0100 (Thu, 28 Jan 2010)
New Revision: 977

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/model/case.py (CaseDigest.getDescription)
(CaseDigest.getValue): New methods to return the description and
value of a formed field.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-01-28 11:09:07 UTC (rev 976)
+++ wasko/branches/2.0/ChangeLog	2010-01-28 11:12:38 UTC (rev 977)
@@ -1,5 +1,11 @@
 2010-01-28  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/model/case.py (CaseDigest.getDescription)
+	(CaseDigest.getValue): New methods to return the description and
+	value of a formed field.
+
+2010-01-28  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/controllers/case.py (CaseController.phase): Remove
 	references to session_case. It was only used to fetch the mode,
 	which isn't really used anymore and is currently always "show"

Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py	2010-01-28 11:09:07 UTC (rev 976)
+++ wasko/branches/2.0/waskaweb/model/case.py	2010-01-28 11:12:38 UTC (rev 977)
@@ -693,7 +693,34 @@
         else:
             raise AttributeError(name)
 
+    def getValue(self, name):
+        log.debug("CaseDigest.getValue: name = %r", name)
+        fid = get_field_identifier(self.id, name, self._it)
+        log.debug("CaseDigest.getValue: fid = %r", fid)
+        if fid:
+            item = self._it.getItem(fid)
+            if item:
+                value = item.getValue()
+            if isinstance(value, str):
+                value = unicode(str(value), 'utf-8')
+            self.__dict__[name] = value
+            return value
+        else:
+            raise AttributeError(name)
 
+    def getDescription(self, name):
+        log.debug("CaseDigest.getDescription: name = %r", name)
+        fid = get_field_identifier(self.id, name, self._it)
+        log.debug("CaseDigest.getDescription: fid = %r", fid)
+        if fid:
+            item = self._it.getItem(fid)
+            if item:
+                return item.getMeta().getDescription()
+            return "no description found"
+        else:
+            raise AttributeError(name)
+
+
 class SessionCase:
 
     """This class holds all needed information for the currently selected case



More information about the Mpuls-commits mailing list