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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Oct 8 22:00:07 CEST 2010


Author: bh
Date: 2010-10-08 22:00:05 +0200 (Fri, 08 Oct 2010)
New Revision: 3950

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/validators.py
Log:
* mpulsweb/lib/validators.py (MyDateConverter.unconvert_day): New.
Called by the from_python method to convert back from a python
date object to the string representation.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-10-08 19:34:09 UTC (rev 3949)
+++ base/trunk/ChangeLog	2010-10-08 20:00:05 UTC (rev 3950)
@@ -1,5 +1,11 @@
 2010-10-08  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/validators.py (MyDateConverter.unconvert_day): New.
+	Called by the from_python method to convert back from a python
+	date object to the string representation.
+
+2010-10-08  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/controllers/evaluate.py (EvaluateController.evaluate):
 	evaloptions is only used within the evaluate method so there's no
 	need to put it into the c-Object

Modified: base/trunk/mpulsweb/lib/validators.py
===================================================================
--- base/trunk/mpulsweb/lib/validators.py	2010-10-08 19:34:09 UTC (rev 3949)
+++ base/trunk/mpulsweb/lib/validators.py	2010-10-08 20:00:05 UTC (rev 3950)
@@ -232,6 +232,19 @@
         if not self.month_style in ('dd/mm/yyyy', 'mm/dd/yyyy', 'dd.mm.jjjj'):
             raise TypeError("Bad month_style: %r" % self.month_style)
 
+    def unconvert_day(self, value, state):
+        """Convert back from the date object value to a string representation.
+        This method is called indirectly by the from_python method of
+        the base classes.  In MyDateConverter we only handle the
+        additional case of the 'dd.mm.jjjj' style.  The others styles
+        are handled by the base class.
+        """
+        if self.month_style == 'dd.mm.jjjj':
+            return value.strftime("%d.%m.%Y")
+        else:
+            return super(MyDateConverter, self).unconvert_day(value, state)
+
+
 class TimeDeltaCheck(FormValidator):
 
     """Tests that the given datetimes do not have a too large timedelta.



More information about the Mpuls-commits mailing list