Show
Ignore:
Timestamp:
10/07/04 23:14:28 (20 years ago)
Author:
jalet
Message:

Hopefully final fix for data encoding to and from the database

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storage.py

    r1755 r1790  
    2222# 
    2323# $Log$ 
     24# Revision 1.63  2004/10/07 21:14:28  jalet 
     25# Hopefully final fix for data encoding to and from the database 
     26# 
    2427# Revision 1.62  2004/09/28 17:45:31  jalet 
    2528# Added the --hardreset command line option to edpykota 
     
    685688        return gpquotas         
    686689         
     690    def databaseToUserCharset(self, text) : 
     691        """Converts from database format (UTF-8) to user's charset.""" 
     692        if text is not None : 
     693            try : 
     694                return unicode(text, "UTF-8").encode(self.tool.getCharset())  
     695            except UnicodeError :     
     696                pass 
     697        return text 
     698         
     699    def userCharsetToDatabase(self, text) : 
     700        """Converts from user's charset to database format (UTF-8).""" 
     701        if text is not None : 
     702            try : 
     703                return unicode(text, self.tool.getCharset()).encode("UTF-8")  
     704            except UnicodeError :     
     705                pass 
     706        return text 
     707         
    687708def openConnection(pykotatool) : 
    688709    """Returns a connection handle to the appropriate Quota Storage Database."""