dabo Commit
Revision 2357
Date: 2006-10-16 17:59:50 -0700 (Mon, 16 Oct 2006)
Author: paul

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

Log:
Added a miniscule amount of documentation to dBizobj's scan() function, and 
another comment in setFieldVal() about my growing desire to ditch the 
__setattr__() function calling setFieldVal(). 

Added a check for None values in dCursorMixin's correctFieldType() function.
None values shouldn't be converted.



Diff:
Modified: trunk/dabo/biz/dBizobj.py
===================================================================
--- trunk/dabo/biz/dBizobj.py   2006-10-16 18:09:25 UTC (rev 2356)
+++ trunk/dabo/biz/dBizobj.py   2006-10-17 00:59:50 UTC (rev 2357)
@@ -848,6 +848,8 @@
 
                If runRequery is True, and the record pointer is moved, all 
child bizobjs
                will be requeried, and the afterPointerMove() hook method will 
fire.
+
+               Returns the RowNumber of the found record, or -1 if no match 
found.
                """
                ret = self._CurrentCursor.seek(val, fld, caseSensitive, near)
                if ret != -1:
@@ -1119,6 +1121,11 @@
                                        return cursor.setFieldVal(fld, val)
                                except dException.NoRecordsException:
                                        return False
+                       else:
+                               ## Can't do the line below like I'd like 
because setFieldVal() runs from
+                               ## __setattr__() and we could be processing 
fld's with values like "UserSQL"...
+                               #raise dException.FieldNotFoundException, 
"Field %s not defined in the DataStructure" % fld
+                               pass
                # If the field doesn't exist in the datastructure, or if there 
isn't a
                # CurrentCursor, return False to let __setattr__ know that the 
attribute
                # should get set to the instance. Note: we should get rid of 
the 

Modified: trunk/dabo/db/dCursorMixin.py
===================================================================
--- trunk/dabo/db/dCursorMixin.py       2006-10-16 18:09:25 UTC (rev 2356)
+++ trunk/dabo/db/dCursorMixin.py       2006-10-17 00:59:50 UTC (rev 2357)
@@ -154,12 +154,19 @@
 
                        if pythonType is not type(None) and not 
isinstance(field_val, pythonType):
                                if pythonType in (datetime.datetime, 
datetime.date):
+                                       # Conversion happens elsewhere.
                                        pass
                                elif pythonType in (unicode,):
-                                       # unicode conversion happens below.
+                                       # Unicode conversion happens below.
                                        pass
+                               elif field_val is None:
+                                       # Fields of any type can be None (NULL).
+                                       pass
                                else:
-                                       ret = pythonType(field_val)
+                                       try:
+                                               ret = pythonType(field_val)
+                                       except Exception, e:
+                                               print "%s couldn't be converted 
to %s (field %s)" % (field_val, pythonType, field_name)
 
                # Do the unicode conversion last:
                if isinstance(field_val, str) and self._convertStrToUnicode:




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to