[Mpuls-commits] r3972 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Oct 13 15:19:01 CEST 2010


Author: bh
Date: 2010-10-13 15:18:59 +0200 (Wed, 13 Oct 2010)
New Revision: 3972

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/config.py
Log:
* mpulsweb/lib/config.py (MpulsAppConfig.get_date): New.  Return a
configuration setting as a date object.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-10-13 10:52:46 UTC (rev 3971)
+++ base/trunk/ChangeLog	2010-10-13 13:18:59 UTC (rev 3972)
@@ -1,5 +1,10 @@
 2010-10-13  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/config.py (MpulsAppConfig.get_date): New.  Return a
+	configuration setting as a date object.
+
+2010-10-13  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/config.py (MpulsAppConfig.get_elementary_fields)
 	(MpulsAppConfig.get_individual_fields): Removed because they're
 	not used anywhere not even in the pre-mpuls-2 applications.

Modified: base/trunk/mpulsweb/lib/config.py
===================================================================
--- base/trunk/mpulsweb/lib/config.py	2010-10-13 10:52:46 UTC (rev 3971)
+++ base/trunk/mpulsweb/lib/config.py	2010-10-13 13:18:59 UTC (rev 3972)
@@ -361,6 +361,19 @@
             log.exception('Error on checking config (%s, %s)' % (section, name))
             return False
 
+    def get_date(self, section, name):
+        """Return the value for section and name interpreted as a date.
+        The value should either be an empty string in which case None is
+        returned or a string in ISO format (YYYY-MM-DD) which is
+        converted to a date object.  If the given configuration setting
+        doesn't exist, None is returned.
+        """
+        value = self.get(section, name)
+        if value:
+            return datetime.date(*[int(part) for part in value.split("-")])
+        else:
+            return None
+
     def get_app_name(self):
         return self.get('common', 'name')
 



More information about the Mpuls-commits mailing list