dabo Commit
Revision 7284
Date: 2012-11-15 05:35:41 -0800 (Thu, 15 Nov 2012)
Author: Jacekk
Trac: http://trac.dabodev.com/changeset/7284

Changed:
U   trunk/dabo/biz/dBizobj.py
U   trunk/dabo/db/dBackend.py
U   trunk/dabo/db/dCursorMixin.py
U   trunk/dabo/settings.py
U   trunk/dabo/ui/dDataControlMixinBase.py

Log:
Added extended support for character type fields in dBizobj and dCursorMixin 
DataStructure property.
Now fifth tuple field contains size of character field.
New global framework setting dTextBox_DeriveTextLengthFromSource has been added 
(default False), allowing to take benefits of changes in text based controls.

Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2012-10-17 02:14:27 UTC (rev 7283)
+++ trunk/dabo/biz/dBizobj.py   2012-11-15 13:35:41 UTC (rev 7284)
@@ -3129,7 +3129,8 @@
                                | 2: pk field (bool)
                                | 3: table name (str)
                                | 4: field name (str)
-                               | 5: field scale (int or None)
+                               | 5: field scale for numeric, display size for 
character
+                                       type fields (int or None)
 
                                This information will try to come from a few 
places, in order:
 

Modified: trunk/dabo/db/dBackend.py
===================================================================
--- trunk/dabo/db/dBackend.py   2012-10-17 02:14:27 UTC (rev 7283)
+++ trunk/dabo/db/dBackend.py   2012-11-15 13:35:41 UTC (rev 7284)
@@ -203,7 +203,7 @@
 
                If it can't be determined, the field type will be '?'.
                """
-               return "?"
+               return {int: "I", str: "C", float: "F"}.get(backendFieldType, 
"?")
 
 
        def getFieldInfoFromDescription(self, cursorDescription):
@@ -345,7 +345,7 @@
                """
                clauses =  (fieldClause, fromClause, joinClause, whereClause, 
groupByClause,
                                orderByClause, limitClause)
-               sql = "select " + "\n".join( [clause for clause in clauses if 
clause] )
+               sql = "select " + "\n".join([clause for clause in clauses if 
clause])
                return sql
 
 
@@ -470,7 +470,7 @@
                # Get the raw version of the table
                sql = "select * from %s where 1=0 " % 
self.encloseNames(cursor.Table,
                                autoQuote=autoQuote)
-               auxCrs.execute( sql )
+               auxCrs.execute(sql)
                # This is the clean version of the table.
                stdFlds = auxCrs.FieldDescription
 
@@ -502,10 +502,11 @@
                        aux.execute(structure_only_sql)
                        field_description = aux.FieldDescription
                for field_info in field_description:
-                       field_name = field_info[0]
+                       field_name = ustr(field_info[0])
                        field_type = self.getDaboFieldType(field_info[1])
                        field_names.append(field_name)
-                       field_structure[field_name] = (field_type, False)
+                       field_structure[field_name] = (field_type, False,
+                                       max(field_info[2], field_info[3]) or 
None, field_info[5] or None)
 
                standard_fields = cursor.getFields()
                for field_name, field_type, pk in standard_fields:
@@ -515,16 +516,20 @@
                                #      the case if we haven't set the SQL or 
requeried yet.
                                #   2) The field exists in the 
FieldDescription, and FieldDescription
                                #      didn't provide good type information.
-                               if field_structure[field_name][0] == "?":
+                               if field_structure[field_name][0] != field_type:
                                        # Only override what was in 
FieldStructure if getFields() gave better info.
-                                       field_structure[field_name] = 
(field_type, pk)
-                               if pk is True:
+                                       field_structure[field_name] = 
(field_type, pk,
+                                                       
field_structure[field_name][2], field_structure[field_name][3])
+                               elif pk:
                                        # FieldStructure doesn't provide pk 
information:
-                                       field_structure[field_name] = 
(field_structure[field_name][0], pk)
+                                       field_structure[field_name] = 
(field_structure[field_name][0], pk,
+                                                       
field_structure[field_name][2], field_structure[field_name][3])
 
-               ret = []
-               for field in field_names:
-                       ret.append( (field, field_structure[field][0], 
field_structure[field][1]) )
+               ret = [(field, field_structure[field][0], 
field_structure[field][1],
+                               None, None,
+                               field_structure[field][2] if 
field_structure[field][0] == "C"
+                                       else field_structure[field][3])
+                               for field in field_names]
                return tuple(ret)
 
 

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2012-10-17 02:14:27 UTC (rev 7283)
+++ trunk/dabo/db/dCursorMixin.py       2012-11-15 13:35:41 UTC (rev 7284)
@@ -3089,7 +3089,8 @@
                                | 2: pk field (bool)
                                | 3: table name (str)
                                | 4: field name (str)
-                               | 5: field scale (int or None)
+                               | 5: field scale for numeric, display size for 
character
+                                       type fields (int or None)
 
                                This information will try to come from a few 
places, in order:
 

Modified: trunk/dabo/settings.py
===================================================================
--- trunk/dabo/settings.py      2012-10-17 02:14:27 UTC (rev 7283)
+++ trunk/dabo/settings.py      2012-11-15 13:35:41 UTC (rev 7284)
@@ -230,6 +230,10 @@
 
 dTextBox_NumericBlankToZero = False
 
+# When set to True, dTextBox control bound to the dBizobj source takes its 
TextLength
+# property settings from it.
+dTextBox_DeriveTextLengthFromSource = False
+
 # When we copy values from a grid, we need to define the following values for 
the copied text:
 copyValueSeparator = "\t"
 copyStringSeparator= '"'

Modified: trunk/dabo/ui/dDataControlMixinBase.py
===================================================================
--- trunk/dabo/ui/dDataControlMixinBase.py      2012-10-17 02:14:27 UTC (rev 
7283)
+++ trunk/dabo/ui/dDataControlMixinBase.py      2012-11-15 13:35:41 UTC (rev 
7284)
@@ -14,6 +14,7 @@
 class dDataControlMixinBase(dabo.ui.dControlMixin):
        """Provide common functionality for the data-aware controls."""
        def __init__(self, *args, **kwargs):
+               self._deriveTextLengthFromSource = 
dabo.dTextBox_DeriveTextLengthFromSource
                self._disableOnEmptyDataSource = dabo.autoDisableDataControls
                self._fldValidFailed = False
                # Control enabling/disabling on empty data source helper 
attribute.
@@ -537,6 +538,14 @@
                                # It's tricky, because object 
attribute/property takes precedence before data field of the same name.
                                if self._srcIsBizobj:
                                        self._srcIsBizobj = not 
hasattr(self.__src, self.DataField)
+                       if self._srcIsBizobj and 
self._deriveTextLengthFromSource and \
+                                       hasattr(self, "TextLength"):
+                               field = self.DataField
+                               for descr in self.__src.DataStructure:
+                                       if descr[0] == field:
+                                               if descr[1] == "C":
+                                                       self.TextLength = 
descr[5]
+                                               break
                return self.__src
 
 



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.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