Show
Ignore:
Timestamp:
10/02/04 07:48:56 (20 years ago)
Author:
jalet
Message:

Should now correctly deal with charsets both when storing into databases and when
retrieving datas. Works with both PostgreSQL and LDAP.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1754 r1761  
    2222# 
    2323# $Log$ 
     24# Revision 1.78  2004/10/02 05:48:56  jalet 
     25# Should now correctly deal with charsets both when storing into databases and when 
     26# retrieving datas. Works with both PostgreSQL and LDAP. 
     27# 
    2428# Revision 1.77  2004/09/28 14:29:00  jalet 
    2529# dumpykota for LDAP backend is almost there. 
     
    576580            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    577581            printer.uniqueMember = fields.get("uniqueMember", []) 
    578             printer.Description = fields.get("description", [""])[0] 
     582            printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    579583            printer.Exists = 1 
    580584        return printer     
     
    677681                    lastjob.JobPrice = None 
    678682                lastjob.JobAction = fields.get("pykotaAction", [""])[0] 
    679                 lastjob.JobFileName = fields.get("pykotaFileName", [""])[0] 
    680                 lastjob.JobTitle = fields.get("pykotaTitle", [""])[0] 
     683                lastjob.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     684                lastjob.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    681685                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    682                 lastjob.JobOptions = fields.get("pykotaOptions", [""])[0] 
     686                lastjob.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    683687                lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
    684688                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
     
    753757                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    754758                printer.uniqueMember = fields.get("uniqueMember", []) 
    755                 printer.Description = fields.get("description", [""])[0] 
     759                printer.Description = fields.get("description", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    756760                printer.Exists = 1 
    757761                printers.append(printer) 
     
    965969        """Write the printer's description back into the storage.""" 
    966970        fields = { 
    967                    "description" : str(printer.Description), 
     971                   "description" : str(printer.Description).decode(self.tool.getCharset()).encode("UTF-8"),  
    968972                 } 
    969973        self.doModify(printer.ident, fields) 
     
    10641068                   "pykotaPrinterPageCounter" : str(pagecounter), 
    10651069                   "pykotaAction" : action, 
    1066                    "pykotaFileName" : ((filename is None) and "None") or filename.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"),  
    1067                    "pykotaTitle" : ((title is None) and "None") or title.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"),  
     1070                   "pykotaFileName" : ((filename is None) and "None") or filename.decode(self.tool.getCharset()).encode("UTF-8"),  
     1071                   "pykotaTitle" : ((title is None) and "None") or title.decode(self.tool.getCharset()).encode("UTF-8"),  
    10681072                   "pykotaCopies" : str(copies),  
    1069                    "pykotaOptions" : ((options is None) and "None") or options.decode(os.environ.get("CHARSET", "ISO-8859-15")).encode("UTF-8"),  
     1073                   "pykotaOptions" : ((options is None) and "None") or options.decode(self.tool.getCharset()).encode("UTF-8"),  
    10701074                   "pykotaHostName" : str(clienthost),  
    10711075                   "pykotaJobSizeBytes" : str(jobsizebytes), 
     
    11661170                    job.JobPrice = None 
    11671171                job.JobAction = fields.get("pykotaAction", [""])[0] 
    1168                 job.JobFileName = fields.get("pykotaFileName", [""])[0] 
    1169                 job.JobTitle = fields.get("pykotaTitle", [""])[0] 
     1172                job.JobFileName = fields.get("pykotaFileName", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
     1173                job.JobTitle = fields.get("pykotaTitle", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    11701174                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    1171                 job.JobOptions = fields.get("pykotaOptions", [""])[0] 
     1175                job.JobOptions = fields.get("pykotaOptions", [""])[0].decode("UTF-8").encode(self.tool.getCharset())  
    11721176                job.JobHostName = fields.get("pykotaHostName", [""])[0] 
    11731177                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0]