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/storages/ldapstorage.py

    r1777 r1790  
    2222# 
    2323# $Log$ 
     24# Revision 1.83  2004/10/07 21:14:28  jalet 
     25# Hopefully final fix for data encoding to and from the database 
     26# 
    2427# Revision 1.82  2004/10/05 09:59:20  jalet 
    2528# Restore compatibility with Python 2.1 
     
    592595            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    593596            printer.uniqueMember = fields.get("uniqueMember", []) 
    594             printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     597            printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    595598            printer.Exists = 1 
    596599        return printer     
     
    693696                    lastjob.JobPrice = None 
    694697                lastjob.JobAction = fields.get("pykotaAction", [""])[0] 
    695                 lastjob.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    696                 lastjob.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     698                lastjob.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0])  
     699                lastjob.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0])  
    697700                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    698                 lastjob.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     701                lastjob.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0])  
    699702                lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
    700703                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
     
    769772                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    770773                printer.uniqueMember = fields.get("uniqueMember", []) 
    771                 printer.Description = unicode(fields.get("description", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     774                printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    772775                printer.Exists = 1 
    773776                printers.append(printer) 
     
    981984        """Write the printer's description back into the storage.""" 
    982985        fields = { 
    983                    "description" : unicode(str(printer.Description), self.tool.getCharset()).encode("UTF-8"),  
     986                   "description" : self.userCharsetToDatabase(str(printer.Description)),  
    984987                 } 
    985988        self.doModify(printer.ident, fields) 
     
    10801083                   "pykotaPrinterPageCounter" : str(pagecounter), 
    10811084                   "pykotaAction" : action, 
    1082                    "pykotaFileName" : ((filename is None) and "None") or unicode(filename, self.tool.getCharset()).encode("UTF-8"),  
    1083                    "pykotaTitle" : ((title is None) and "None") or unicode(title, self.tool.getCharset()).encode("UTF-8"),  
     1085                   "pykotaFileName" : ((filename is None) and "None") or self.userCharsetToDatabase(filename),  
     1086                   "pykotaTitle" : ((title is None) and "None") or self.userCharsetToDatabase(title),  
    10841087                   "pykotaCopies" : str(copies),  
    1085                    "pykotaOptions" : ((options is None) and "None") or unicode(options, self.tool.getCharset()).encode("UTF-8"),  
     1088                   "pykotaOptions" : ((options is None) and "None") or self.userCharsetToDatabase(options),  
    10861089                   "pykotaHostName" : str(clienthost),  
    10871090                   "pykotaJobSizeBytes" : str(jobsizebytes), 
     
    11821185                    job.JobPrice = None 
    11831186                job.JobAction = fields.get("pykotaAction", [""])[0] 
    1184                 job.JobFileName = unicode(fields.get("pykotaFileName", [""])[0], "UTF-8").encode(self.tool.getCharset())  
    1185                 job.JobTitle = unicode(fields.get("pykotaTitle", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     1187                job.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0])  
     1188                job.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0])  
    11861189                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    1187                 job.JobOptions = unicode(fields.get("pykotaOptions", [""])[0], "UTF-8").encode(self.tool.getCharset())  
     1190                job.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0])  
    11881191                job.JobHostName = fields.get("pykotaHostName", [""])[0] 
    11891192                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]