Changeset 322

Show
Ignore:
Timestamp:
04/03/08 04:23:24 (8 months ago)
Author:
johnbywater
Message:

Improved data migration error handling.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/dm/migrate.py

    r308 r322  
    176176                    className, objectId, objectData 
    177177                ) 
    178                 #print msg 
     178                self.logger.info(msg) 
    179179                strObjectData = {} 
    180180                for attr in domainClass.meta.attributes: 
     
    192192                                if idMapKey in self.idMap.keys(): 
    193193                                    mappedValue = self.idMap[idMapKey] 
    194                                     msg = "Updating %s %s from %s to %s" % ( 
    195                                         className, 
    196                                         attr.name, 
    197                                         value, 
    198                                         mappedValue, 
    199                                    
     194                                    #msg = "Updating %s %s from %s to %s" % ( 
     195                                    #    className, 
     196                                    #    attr.name, 
     197                                    #    value, 
     198                                    #    mappedValue, 
     199                                    #
    200200                                    #print msg 
    201201                                    value = mappedValue 
    202202                            if value.__class__ == unicode: 
    203203                                # SQLObject doesn't handle unicode. 
    204                                 value = value.encode()  
     204                                try: 
     205                                    value = str(value) 
     206                                except: 
     207                                    msg = "Failed to convert unicode to str" 
     208                                    msg += " for '%s' of %s %s: %s" % ( 
     209                                        attr.name, className, objectId, value 
     210                                    ) 
     211                                    self.logger.error(msg) 
     212                                    msg = "Continuing with null string value." 
     213                                    self.logger.info(msg) 
     214                                    value = "" 
     215 
    205216                            strObjectData[attr.name] = value 
    206217                objectDict = MultiValueDict()