dabo Commit
Revision 4101
Date: 2008-05-27 16:09:05 -0700 (Tue, 27 May 2008)
Author: Paul
Trac: http://svn.dabodev.com/trac/dabo/changeset/4101

Changed:
U   trunk/dabo/ui/uiwx/dGrid.py

Log:
This continues fixes from my last commit, to allow for None values in some 
string
columns.


Diff:
Modified: trunk/dabo/ui/uiwx/dGrid.py
===================================================================
--- trunk/dabo/ui/uiwx/dGrid.py 2008-05-27 22:52:03 UTC (rev 4100)
+++ trunk/dabo/ui/uiwx/dGrid.py 2008-05-27 23:09:05 UTC (rev 4101)
@@ -2637,7 +2637,12 @@
                        sortList.append( [val, i] )
 
                # Determine if we are seeking string values
-               compString = isinstance(sortList[0][0], basestring)
+               compString = False
+               for row in sortList:
+                       if row[0] is not None:
+                               compString = isinstance(row[0], basestring)
+                               break
+
                if not compString:
                        # coerce srchVal to be the same type as the field type
                        listval = sortList[0][0]
@@ -2673,11 +2678,11 @@
                if compString:
                        if caseSensitive:
                                mtchs = [vv for vv in sortList
-                                               if vv[0].startswith(srchVal)]
+                                               if isinstance(vv[0], 
basestring) and vv[0].startswith(srchVal)]
                        else:
                                srchVal = srchVal.lower()
                                mtchs = [vv for vv in sortList
-                                               if 
vv[0].lower().startswith(srchVal)]
+                                               if isinstance(vv[0], 
basestring) and vv[0].lower().startswith(srchVal)]
                else:
                        mtchs = [vv for vv in sortList
                                        if vv[0] == srchVal]
@@ -2691,7 +2696,7 @@
                                        match = (fldval == srchVal)
                                else:
                                        # Case-insensitive string search.
-                                       match = (fldval.lower() == srchVal)
+                                       match = (isinstance(fldval, basestring) 
and fldval.lower() == srchVal)
                                if match:
                                        newRow = row
                                        break
@@ -2702,7 +2707,7 @@
                                        # requested matching value. If so, 
update the value of 'ret'. If not,
                                        # we have passed the matching value, so 
there's no point in
                                        # continuing the search, but we mu
-                                       if compString and not caseSensitive:
+                                       if compString and not caseSensitive and 
isinstance(fldval, basestring):
                                                toofar = fldval.lower() > 
srchVal
                                        else:
                                                toofar = fldval > srchVal




_______________________________________________
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