Changeset 1913

Show
Ignore:
Timestamp:
02/09/06 08:27:15 (3 years ago)
Author:
paul
Message:

The automatic switching of encodings was resulting in a trial and a message
for every single failing field. Modified to persist the changing of the
encoding and to log just one message.

I'm wondering... this iterating of the fields in the resultset is adding
a lot of overhead to every requery... do the various backends offer
conversion to unicode for us perhaps?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/db/dCursorMixin.py

    r1912 r1913  
    218218                                row[fld]= unicode(val, self.Encoding) 
    219219                            except UnicodeDecodeError, e: 
    220                                 # Try the main two encodings 
     220                                # Try some common encodings: 
    221221                                ok = False 
    222222                                for enc in ("utf8", "latin-1"): 
     
    225225                                            row[fld]= unicode(val, enc) 
    226226                                            ok = True 
    227                                             break 
    228227                                        except UnicodeDecodeError: 
    229228                                            continue 
    230                                 if ok: 
    231                                     # Should we change self.Encoding at this point? 
    232                                     dabo.errorLog.write(_("Incorrect unicode encoding set; using '%s' instead") 
     229                                        if ok: 
     230                                            # change self.Encoding and log the message 
     231                                            self.Encoding = enc 
     232                                            dabo.errorLog.write(_("Incorrect unicode encoding set; using '%s' instead") 
    233233                                            % enc) 
     234                                            break 
    234235                                else: 
    235236                                    raise UnicodeDecodeError, e