dabo Commit
Revision 7249
Date: 2012-09-13 12:28:17 -0700 (Thu, 13 Sep 2012)
Author: Paul
Trac: http://trac.dabodev.com/changeset/7249

Changed:
U   trunk/dabo/lib/reportWriter.py

Log:
Added Report property StringifyDates. When True (the default), if a String 
object's expr property evaluates to a datetime.date, the report writer will
run that through dabo.lib.dates.getStringFromDate(), which will format the
date according to the user's locale (or dabo.dateFormat if set).

I got tired of having to remember to put this into my report expressions
manually.


Diff:
Modified: trunk/dabo/lib/reportWriter.py
===================================================================
--- trunk/dabo/lib/reportWriter.py      2012-09-12 22:30:03 UTC (rev 7248)
+++ trunk/dabo/lib/reportWriter.py      2012-09-13 19:28:17 UTC (rev 7249)
@@ -9,6 +9,7 @@
 import sys
 import os
 from dabo.dLocalize import _
+from dabo.lib.dates import getStringFromDate
 
 ######################################################
 # Very first thing: check for required libraries:
@@ -608,6 +609,11 @@
                self.AvailableProps["ColumnPadding"] = toPropDict(float, 0,
                                """Specifies how much space to leave in between 
columns.""")
 
+               self.AvailableProps["StringifyDates"] = toPropDict(bool, True,
+                               """If True, expressions in String objects that 
evaluate to a datetime.date will get displayed 
+                               in the report as a string as returned by 
dabo.lib.getStringFromDate(), which will
+                               result in the date getting displayed as set by 
dabo.dateFormat or the user's locale.""")
+
                self.MajorProperty = "Title"
 
 
@@ -1624,6 +1630,8 @@
 
                        if s is None:
                                s = self.NoneDisplay
+                       elif obj.Report.getProp("StringifyDates") and 
isinstance(s, datetime.date):
+                               s = getStringFromDate(s)
 
                        func(posx, 0, ustr(s))
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to