Changeset 3364

Show
Ignore:
Timestamp:
04/01/08 18:15:33 (13 years ago)
Author:
jerome
Message:

Tried to fix remaining LDAP encoding problems... Untested.

Files:
1 modified

Legend:

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

    r3363 r3364  
    320320        result = self.doSearch(ldapfilter, ["pykotaBillingCode"], base=self.info["billingcodebase"]) 
    321321        if result : 
    322             return [databaseToUnicode(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)] 
     322            return self.filterNames(result, "pykotaBillingCode", billingcode) 
    323323        else :     
    324324            return [] 
     
    365365            user.ident = result[0][0] 
    366366            user.Description = databaseToUnicode(fields.get("description", [None])[0]) 
    367             user.Email = fields.get(self.info["usermail"], [None])[0] 
     367            user.Email = databaseToUnicode(fields.get(self.info["usermail"], [None])[0]) 
    368368            user.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0]) 
    369369            result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["balancerdn"], username), ["pykotaBalance", "pykotaLifeTimePaid", "pykotaPayments", "pykotaOverCharge"], base=self.info["balancebase"]) 
     
    412412            fields = result[0][1] 
    413413            group.ident = result[0][0] 
    414             group.Name = fields.get("pykotaGroupName", [databaseToUnicode(groupname)])[0]  
     414            group.Name = databaseToUnicode(fields.get("pykotaGroupName", [groupname])[0]) 
    415415            group.Description = databaseToUnicode(fields.get("description", [None])[0]) 
    416416            group.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0]) 
     
    437437            fields = result[0][1]       # take only first matching printer, ignore the rest 
    438438            printer.ident = result[0][0] 
    439             printer.Name = fields.get("pykotaPrinterName", [databaseToUnicode(printername)])[0]  
     439            printer.Name = databaseToUnicode(fields.get("pykotaPrinterName", [printername])[0]) 
    440440            printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 
    441441            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) 
     
    592592                fields = result[0][1] 
    593593                lastjob.ident = result[0][0] 
    594                 lastjob.JobId = fields.get("pykotaJobId")[0] 
     594                lastjob.JobId = databaseToUnicode(fields.get("pykotaJobId")[0]) 
    595595                lastjob.UserName = databaseToUnicode(fields.get("pykotaUserName")[0]) 
    596596                lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter", [0])[0]) 
     
    603603                except ValueError :     
    604604                    lastjob.JobPrice = None 
    605                 lastjob.JobAction = fields.get("pykotaAction", [""])[0] 
     605                lastjob.JobAction = databaseToUnicode(fields.get("pykotaAction", [""])[0]) 
    606606                lastjob.JobFileName = databaseToUnicode(fields.get("pykotaFileName", [""])[0])  
    607607                lastjob.JobTitle = databaseToUnicode(fields.get("pykotaTitle", [""])[0])  
    608608                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    609609                lastjob.JobOptions = databaseToUnicode(fields.get("pykotaOptions", [""])[0])  
    610                 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
     610                lastjob.JobHostName = databaseToUnicode(fields.get("pykotaHostName", [""])[0]) 
    611611                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
    612612                lastjob.JobBillingCode = databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 
    613                 lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
     613                lastjob.JobMD5Sum = databaseToUnicode(fields.get("pykotaMD5Sum", [None])[0]) 
    614614                lastjob.JobPages = fields.get("pykotaPages", [""])[0] 
    615615                try : 
     
    621621                except ValueError :     
    622622                    lastjob.PrecomputedJobPrice = None 
    623                 if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == "hidden" : 
     623                if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == u"hidden" : 
    624624                    (lastjob.JobTitle, lastjob.JobFileName, lastjob.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
    625625                date = fields.get("createTimestamp", ["19700101000000Z"])[0] # It's in UTC ! 
     
    745745                    user = StorageUser(self, username) 
    746746                    user.ident = userid 
    747                     user.Email = fields.get(self.info["usermail"], [None])[0] 
     747                    user.Email = databaseToUnicode(fields.get(self.info["usermail"], [None])[0]) 
    748748                    user.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0]) 
    749749                    user.Description = databaseToUnicode(fields.get("description", [""])[0])  
     
    812812                    group = StorageGroup(self, groupname) 
    813813                    group.ident = groupid 
    814                     group.Name = fields.get("pykotaGroupName", [groupname])[0]  
     814                    group.Name = databaseToUnicode(fields.get("pykotaGroupName", [groupname])[0])  
    815815                    group.LimitBy = databaseToUnicode(fields.get("pykotaLimitBy", ["quota"])[0]) 
    816816                    group.Description = databaseToUnicode(fields.get("description", [""])[0])  
     
    923923                       "pykotaLimitBy" : unicodeToDatabase(user.LimitBy or u"quota"), 
    924924                       "description" : unicodeToDatabase(user.Description or ""), 
    925                        self.info["usermail"] : user.Email or "", 
     925                       self.info["usermail"] : unicodeToDatabase(user.Email or ""), 
    926926                    }    
    927927                        
     
    12071207        if self.privacy :     
    12081208            # For legal reasons, we want to hide the title, filename and options 
    1209             title = filename = options = "hidden" 
     1209            title = filename = options = u"hidden" 
    12101210        fields = { 
    12111211                   "objectClass" : ["pykotaObject", "pykotaJob"], 
     
    12131213                   "pykotaUserName" : uname, 
    12141214                   "pykotaPrinterName" : pname, 
    1215                    "pykotaJobId" : jobid, 
     1215                   "pykotaJobId" : unicodeToDatabase(jobid), 
    12161216                   "pykotaPrinterPageCounter" : str(pagecounter), 
    1217                    "pykotaAction" : action, 
     1217                   "pykotaAction" : unicodeToDatabase(action), 
    12181218                   "pykotaFileName" : ((filename is None) and "None") or unicodeToDatabase(filename),  
    12191219                   "pykotaTitle" : ((title is None) and "None") or unicodeToDatabase(title),  
     
    12221222                   "pykotaHostName" : str(clienthost),  
    12231223                   "pykotaJobSizeBytes" : str(jobsizebytes), 
    1224                    "pykotaMD5Sum" : str(jobmd5sum), 
     1224                   "pykotaMD5Sum" : unicodeToDatabase(jobmd5sum), 
    12251225                   "pykotaPages" : jobpages,            # don't add this attribute if it is not set, so no string conversion 
    12261226                   "pykotaBillingCode" : unicodeToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion 
     
    13541354                job = StorageJob(self) 
    13551355                job.ident = ident 
    1356                 job.JobId = fields.get("pykotaJobId")[0] 
     1356                job.JobId = databaseToUnicode(fields.get("pykotaJobId")[0]) 
    13571357                job.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter", [0])[0] or 0) 
    13581358                try : 
     
    13641364                except ValueError : 
    13651365                    job.JobPrice = None 
    1366                 job.JobAction = fields.get("pykotaAction", [""])[0] 
     1366                job.JobAction = databaseToUnicode(fields.get("pykotaAction", [""])[0]) 
    13671367                job.JobFileName = databaseToUnicode(fields.get("pykotaFileName", [""])[0])  
    13681368                job.JobTitle = databaseToUnicode(fields.get("pykotaTitle", [""])[0])  
    13691369                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    13701370                job.JobOptions = databaseToUnicode(fields.get("pykotaOptions", [""])[0])  
    1371                 job.JobHostName = fields.get("pykotaHostName", [""])[0] 
     1371                job.JobHostName = databaseToUnicode(fields.get("pykotaHostName", [""])[0]) 
    13721372                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
    13731373                job.JobBillingCode = databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 
    1374                 job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
     1374                job.JobMD5Sum = databaseToUnicode(fields.get("pykotaMD5Sum", [None])[0]) 
    13751375                job.JobPages = fields.get("pykotaPages", [""])[0] 
    13761376                try : 
     
    13821382                except ValueError : 
    13831383                    job.PrecomputedJobPrice = None 
    1384                 if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" : 
     1384                if job.JobTitle == job.JobFileName == job.JobOptions == u"hidden" : 
    13851385                    (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
    13861386                date = fields.get("createTimestamp", ["19700101000000Z"])[0] # It's in UTC !