Re: [dabo-dev] dabo Commit 4040

Author: Ed Leafe

Posted: 2008-04-15 at 19:53:35

On Apr 15, 2008, at 6:16 PM, Paul McNett wrote:

> Commented out the raising of ValueError in getDataTypeForField(),

> as I was getting lots of Dabo Error Log entries for virtual fields.

>

> This matches the doc which says the function will return None if

> there isn't any DataStructure information for the field.

This was the 'syntax error' that John Fabiani was getting last week.

I had created a fix and sent it to him, and was waiting for

confirmation that it solved his problem. I know that the docstring

said it would return None if the field isn't in the DataStructure, but

I think that if we can determine the field type, we should return it,

no?

Here's my fix; try it out on your stuff and let me know if it works

for you. If it's OK, we can change the docstring to reflect this change.

def getDataTypeForField(self, fld):

"""Given a field name, returns its Python type, or None if no

DataStructure information is available.

"""

if fld in self.VirtualFields:

return type(self.getFieldVal(fld))

ds = self.getDataStructure()

if not ds:

return None

try:

fldInfo = [rec[1] for rec in ds

if rec[0] == fld][0]

except IndexError:

raise ValueError, _("Field '%s' does not exist in the

DataStructure") % fld

return dabo.db.getPythonType(fldInfo)

-- Ed Leafe

©2008 Ed Leafe