dabo Commit
Revision 7180
Date: 2012-05-15 10:24:29 -0700 (Tue, 15 May 2012)
Author: Ed
Trac: http://trac.dabodev.com/changeset/7180

Changed:
U   trunk/dabo/db/dCursorMixin.py

Log:
Changed the default precision from 2 to the number of decimal places in a 
Decimal value when it is not explicitly set in the DataStructure.

Diff:
Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2012-05-15 17:21:09 UTC (rev 7179)
+++ trunk/dabo/db/dCursorMixin.py       2012-05-15 17:24:29 UTC (rev 7180)
@@ -260,13 +260,16 @@
                                # Can't convert to decimal directly from float
                                _field_val = ustr(_field_val)
                        # Need to convert to the correct scale:
-                       scale = None
-                       for s in ds:
-                               if s[0] == field_name:
-                                       if len(s) > 5:
-                                               scale = s[5]
+                       try:
+                               scale = [s[5] for s in ds
+                                               if s[0] == field_name][0]
+                       except IndexError:
+                               scale = None
                        if scale is None:
-                               scale = 2
+                               try:
+                                       scale = len(_field_val.split(".")[1])
+                               except IndexError:
+                                       scale = 2
                        dec = tryToCorrect(Decimal, _field_val, field_name)
                        return dec.quantize(Decimal("0.%s" % (scale * "0",)))
                else:
@@ -1371,7 +1374,6 @@
                to include, and rows is the number of rows to return.
                """
                rowCount = self.RowCount
-
                if rows is None:
                        rows = rowCount
                else:



_______________________________________________
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