Exemplo n.º 1
0
    def fillObject( self, dbRow, template, objectFields ):

        # create a single object
        obj = type(template)()
 
        # fill fields
        for key, value in zip(objectFields, dbRow):
 
            # check for NULLs
            if value is None:
                obj[key] = deepcopy( template.defaults[key] )
 
            # check for lists
            elif type(template.defaults[key]) == list:
                try :
                    obj[key] = evalCustomList(value)
                except SyntaxError:
                    obj[key] = [ value ]
 
            # other objects get casted automatically
            else:
                obj[key] = value
 
            # mark them as existing in database
            obj.existsInDataBase = True
 
        return obj
Exemplo n.º 2
0
            # create a single object
            # template = deepcopy(template)
            obj = type(template)()

            # fill fields
            for key, value in zip(objectFields, row):

                # check for NULLs
                if value is None:
                    obj[key] = deepcopy(template.defaults[key])

                # check for lists
                elif type(template.defaults[key]) == list:
                    try :
                        obj[key] = evalCustomList(value)
                    except SyntaxError:
                        obj[key] = [ value ]

                # other objects get casted automatically
                else:
                    obj[key] = value

                # mark them as existing in database
                obj.existsInDataBase = True

            # add to list
            theList.append(obj)

        # return the list
        return theList