On 05/14/2012 02:56 PM, Ed Leafe wrote:
> On May 14, 2012, at 4:26 PM, Adrian Klaver wrote:
>
>> http://paul.dabodev.com/doc/api/dabodoc/dabo.ui.uiwx.dGrid.dColumn.html#Properties_DataType
>>
>> DataType
>> Description of the data type for this column  (str)
>>
>> The docs say it calls for a string and that is what I have been using
>> with no ill effects, with the data type strings drawn from here:
>>
>> http://wiki.dabodev.com/DataTypes
>
>       The docs may be in need of updates. ;-) In any case, I believe that 
> "Decimal" will work, but not "decimal.Decimal".

I believe the Dabo code below indicates that DataType is looking for a 
string but will work for a type. The part I don't understand is:
col.DataType = ustr(col.DataType).split("'")[1].lower()
should that not be:
col.DataType = ustr(col.DataType).split(".")[1].lower()

That would catch the "decimal.Decimal", "datetime.date", 
"datetime.datetime" and "datetime.time" cases.

In any case I will change my DataType specifications to match the below.

In dGrid.py:
def setColumns
....
                
if isinstance(col.DataType, type):
     typeDict = {
             str : "string",
             unicode : "unicode",
             bool : "bool",
             int : "integer",
             float : "float",
             long : "long",
             datetime.date : "date",
             datetime.datetime : "datetime",
             datetime.time : "time",
             Decimal: "decimal"}
try:
     col.DataType = typeDict[col.DataType]
except KeyError:
     # Not one of the standard types. Extract it from
     # the string version of the type
     try:
         col.DataType = ustr(col.DataType).split("'")[1].lower()
     except IndexError:
         # Something's odd. Print an error message and move on.
         dabo.log.error("Unknown datatype found in setColumns(): %s"
                         % col.DataType)
         col.DataType =ustr(col.DataType)

>
>       During the debugging for this, I found several places where the 
> specified data types were being ignored, and every column being set to use 
> its stringRenderer class instead of something more specific. In most cases 
> the differences were minimal, except when it came to the Precision property.
>
>       Try this: run one of your apps with a grid, open a Command Window, get 
> a reference to the grid, and then run:
>
> [col._rendererClass for col in gridref.Columns]
>
>       Before the recent changes, this would result in a list of all 
> wx.grid.GridCellStringRenderer instead of the correct renderers for the 
> column types.
>
>
>
> -- Ed Leafe
>
>
>
> _______________________________________________
> Post Messages to: [email protected]
> Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
> Searchable Archives: http://leafe.com/archives/search/dabo-users
> This message: 
> http://leafe.com/archives/byMID/[email protected]
>
>


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

Reply via email to