Changeset 3291

Show
Ignore:
Timestamp:
01/13/08 01:22:35 (16 years ago)
Author:
jerome
Message:

Database backends now convert from and to unicode instead of UTF-8.
The data dumper now expects unicode datas from the database.

Location:
pykota/trunk/pykota
Files:
5 modified

Legend:

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

    r3288 r3291  
    244244                line = [] 
    245245                for value in entry : 
    246                     if type(value).__name__ in ("str", "NoneType") : 
    247                         line.append('"%s"' % str(value).replace(separator, "\\%s" % separator).replace('"', '\\"')) 
    248                     else :     
    249                         line.append(str(value)) 
     246                    try : 
     247                        strvalue = '"%s"' % value.encode(self.charset, \ 
     248                                                         "replace").replace(separator, "\\%s" % separator).replace('"', '\\"') 
     249                    except AttributeError : 
     250                        if value is None : 
     251                            strvalue = '"None"' # Double quotes around None to prevent spreadsheet from failing 
     252                        else :     
     253                            strvalue = str(value) 
     254                    line.append(strvalue) 
    250255                try : 
    251256                    self.outfile.write("%s\n" % separator.join(line)) 
     
    313318                x.entry() 
    314319                for (header, value) in zip(headers, entry) : 
    315                     strvalue = str(value) 
    316                     typval = type(value).__name__ 
    317                     if header in ("filename", "title", "options", "billingcode") \ 
    318                               and (typval == "str") : 
    319                         try : 
    320                             strvalue = unicode(strvalue, self.charset).encode("UTF-8") 
    321                         except UnicodeError :     
    322                             pass 
    323                         strvalue = saxutils.escape(strvalue, { "'" : "'", \ 
    324                                                                '"' : """ }) 
    325                     x.attribute(strvalue, type=typval, name=header) 
     320                    try : 
     321                        strvalue = saxutils.escape(value.encode("UTF-8", \ 
     322                                                                "replace"), \ 
     323                                                   { "'" : "'", \ 
     324                                                     '"' : """ }) 
     325                    except AttributeError :     
     326                        strvalue = str(value) 
     327                    # We use 'str' instead of 'unicode' below to be compatible 
     328                    # with older releases of PyKota. 
     329                    # The XML dump will contain UTF-8 encoded strings,  
     330                    #�not unicode strings anyway. 
     331                    x.attribute(strvalue, \ 
     332                                type=type(value).__name__.replace("unicode", "str"), \ 
     333                                name=header) 
    326334                x._pop()     
    327335            x._pop()     
  • pykota/trunk/pykota/storage.py

    r3288 r3291  
    728728        return gpquotas         
    729729         
    730     def databaseToUserCharset(self, text) : 
    731         """Converts from database format (UTF-8) to user's charset.""" 
    732         return self.tool.UTF8ToUserCharset(text) 
    733          
    734     def userCharsetToDatabase(self, text) : 
    735         """Converts from user's charset to database format (UTF-8).""" 
    736         return self.tool.userCharsetToUTF8(text) 
    737          
     730    def databaseToUnicode(self, text) : 
     731        """Converts from database format (UTF-8) to unicode.""" 
     732        if text is not None : 
     733            return text.decode("UTF-8", "replace") 
     734        else :  
     735            return None 
     736         
     737    def unicodeToDatabase(self, text) : 
     738        """Converts from unicode to database format (UTF-8).""" 
     739        if text is not None :  
     740            return text.encode("UTF-8", "replace") 
     741        else :     
     742            return None 
     743             
    738744    def cleanDates(self, startdate, enddate) :     
    739745        """Clean the dates to create a correct filter.""" 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r3288 r3291  
    303303                self.tool.printInfo("Object %s has no %s attribute !" % (dn, attribute), "error") 
    304304            else : 
    305                 attrval = self.databaseToUserCharset(attrval) 
     305                attrval = self.databaseToUnicode(attrval) 
    306306                if patterns : 
    307307                    if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) : 
     
    318318        result = self.doSearch(ldapfilter, ["pykotaBillingCode"], base=self.info["billingcodebase"]) 
    319319        if result : 
    320             return [self.databaseToUserCharset(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)] 
     320            return [self.databaseToUnicode(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)] 
    321321        else :     
    322322            return [] 
     
    351351    def getUserNbJobsFromHistory(self, user) : 
    352352        """Returns the number of jobs the user has in history.""" 
    353         result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.userCharsetToDatabase(user.Name), None, base=self.info["jobbase"]) 
     353        result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.unicodeToDatabase(user.Name), None, base=self.info["jobbase"]) 
    354354        return len(result) 
    355355         
     
    357357        """Extracts user information given its name.""" 
    358358        user = StorageUser(self, username) 
    359         username = self.userCharsetToDatabase(username) 
     359        username = self.unicodeToDatabase(username) 
    360360        result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "description"], base=self.info["userbase"]) 
    361361        if result : 
    362362            fields = result[0][1] 
    363363            user.ident = result[0][0] 
    364             user.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 
     364            user.Description = self.databaseToUnicode(fields.get("description", [None])[0]) 
    365365            user.Email = fields.get(self.info["usermail"], [None])[0] 
    366366            user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
     
    395395                        description = "" 
    396396                    else :     
    397                         description = self.databaseToUserCharset(base64.decodestring(description)) 
     397                        description = self.databaseToUnicode(base64.decodestring(description)) 
    398398                    if amount.endswith(" #") :     
    399399                        amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think 
     
    405405        """Extracts group information given its name.""" 
    406406        group = StorageGroup(self, groupname) 
    407         groupname = self.userCharsetToDatabase(groupname) 
     407        groupname = self.unicodeToDatabase(groupname) 
    408408        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy", "description"], base=self.info["groupbase"]) 
    409409        if result : 
    410410            fields = result[0][1] 
    411411            group.ident = result[0][0] 
    412             group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0]  
    413             group.Description = self.databaseToUserCharset(fields.get("description", [None])[0]) 
     412            group.Name = fields.get("pykotaGroupName", [self.databaseToUnicode(groupname)])[0]  
     413            group.Description = self.databaseToUnicode(fields.get("description", [None])[0]) 
    414414            group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    415415            group.AccountBalance = 0.0 
     
    425425        """Extracts printer information given its name : returns first matching printer.""" 
    426426        printer = StoragePrinter(self, printername) 
    427         printername = self.userCharsetToDatabase(printername) 
     427        printername = self.unicodeToDatabase(printername) 
    428428        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" \ 
    429429                      % (printername, self.info["printerrdn"], printername), \ 
     
    435435            fields = result[0][1]       # take only first matching printer, ignore the rest 
    436436            printer.ident = result[0][0] 
    437             printer.Name = fields.get("pykotaPrinterName", [self.databaseToUserCharset(printername)])[0]  
     437            printer.Name = fields.get("pykotaPrinterName", [self.databaseToUnicode(printername)])[0]  
    438438            printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 
    439439            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) 
     
    445445                printer.PassThrough = 0 
    446446            printer.uniqueMember = fields.get("uniqueMember", []) 
    447             printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     447            printer.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
    448448            printer.Exists = True 
    449449        return printer     
     
    458458                base = self.info["userquotabase"] 
    459459            result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s)(pykotaPrinterName=%s))" % \ 
    460                                       (self.userCharsetToDatabase(user.Name), self.userCharsetToDatabase(printer.Name)), \ 
     460                                      (self.unicodeToDatabase(user.Name), self.unicodeToDatabase(printer.Name)), \ 
    461461                                      ["pykotaPageCounter", "pykotaLifePageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaWarnCount", "pykotaMaxJobSize"], \ 
    462462                                      base=base) 
     
    503503                base = self.info["groupquotabase"] 
    504504            result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \ 
    505                                       (self.userCharsetToDatabase(group.Name), self.userCharsetToDatabase(printer.Name)), \ 
     505                                      (self.unicodeToDatabase(group.Name), self.unicodeToDatabase(printer.Name)), \ 
    506506                                      ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaMaxJobSize"], \ 
    507507                                      base=base) 
     
    535535                grouppquota.PageCounter = 0 
    536536                grouppquota.LifePageCounter = 0 
    537                 usernamesfilter = "".join(["(pykotaUserName=%s)" % self.userCharsetToDatabase(member.Name) for member in self.getGroupMembers(group)]) 
     537                usernamesfilter = "".join(["(pykotaUserName=%s)" % self.unicodeToDatabase(member.Name) for member in self.getGroupMembers(group)]) 
    538538                if usernamesfilter : 
    539539                    usernamesfilter = "(|%s)" % usernamesfilter 
     
    543543                    base = self.info["userquotabase"] 
    544544                result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s)%s)" % \ 
    545                                           (self.userCharsetToDatabase(printer.Name), usernamesfilter), \ 
     545                                          (self.unicodeToDatabase(printer.Name), usernamesfilter), \ 
    546546                                          ["pykotaPageCounter", "pykotaLifePageCounter"], base=base) 
    547547                if result : 
     
    555555        """Extracts a printer's last job information.""" 
    556556        lastjob = StorageLastJob(self, printer) 
    557         pname = self.userCharsetToDatabase(printer.Name) 
     557        pname = self.unicodeToDatabase(printer.Name) 
    558558        result = self.doSearch("(&(objectClass=pykotaLastjob)(|(pykotaPrinterName=%s)(%s=%s)))" % \ 
    559559                                  (pname, self.info["printerrdn"], pname), \ 
     
    591591                lastjob.ident = result[0][0] 
    592592                lastjob.JobId = fields.get("pykotaJobId")[0] 
    593                 lastjob.UserName = self.databaseToUserCharset(fields.get("pykotaUserName")[0]) 
     593                lastjob.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0]) 
    594594                lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter", [0])[0]) 
    595595                try : 
     
    602602                    lastjob.JobPrice = None 
    603603                lastjob.JobAction = fields.get("pykotaAction", [""])[0] 
    604                 lastjob.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0])  
    605                 lastjob.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0])  
     604                lastjob.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0])  
     605                lastjob.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0])  
    606606                lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    607                 lastjob.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0])  
     607                lastjob.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0])  
    608608                lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 
    609609                lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
    610                 lastjob.JobBillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [None])[0]) 
     610                lastjob.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 
    611611                lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
    612612                lastjob.JobPages = fields.get("pykotaPages", [""])[0] 
     
    630630        """Returns the group's members list.""" 
    631631        groupmembers = [] 
    632         gname = self.userCharsetToDatabase(group.Name) 
     632        gname = self.unicodeToDatabase(group.Name) 
    633633        result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % \ 
    634634                                  (gname, self.info["grouprdn"], gname), \ 
     
    637637        if result : 
    638638            for username in result[0][1].get(self.info["groupmembers"], []) : 
    639                 groupmembers.append(self.getUser(self.databaseToUserCharset(username))) 
     639                groupmembers.append(self.getUser(self.databaseToUnicode(username))) 
    640640        return groupmembers         
    641641         
     
    643643        """Returns the user's groups list.""" 
    644644        groups = [] 
    645         uname = self.userCharsetToDatabase(user.Name) 
     645        uname = self.unicodeToDatabase(user.Name) 
    646646        result = self.doSearch("(&(objectClass=pykotaGroup)(%s=%s))" % \ 
    647647                                  (self.info["groupmembers"], uname), \ 
     
    650650        if result : 
    651651            for (groupid, fields) in result : 
    652                 groupname = self.databaseToUserCharset((fields.get("pykotaGroupName", [None]) or fields.get(self.info["grouprdn"], [None]))[0]) 
     652                groupname = self.databaseToUnicode((fields.get("pykotaGroupName", [None]) or fields.get(self.info["grouprdn"], [None]))[0]) 
    653653                group = self.getFromCache("GROUPS", groupname) 
    654654                if group is None : 
     
    681681            for (printerid, fields) in result : 
    682682                if printerid != printer.ident : # In case of integrity violation. 
    683                     parentprinter = self.getPrinter(self.databaseToUserCharset(fields.get("pykotaPrinterName")[0])) 
     683                    parentprinter = self.getPrinter(self.databaseToUnicode(fields.get("pykotaPrinterName")[0])) 
    684684                    if parentprinter.Exists : 
    685685                        pgroups.append(parentprinter) 
     
    703703                    patdict[p] = None 
    704704            for (printerid, fields) in result : 
    705                 printername = self.databaseToUserCharset(fields.get("pykotaPrinterName", [""])[0] or fields.get(self.info["printerrdn"], [""])[0]) 
     705                printername = self.databaseToUnicode(fields.get("pykotaPrinterName", [""])[0] or fields.get(self.info["printerrdn"], [""])[0]) 
    706706                if patdict.has_key(printername) or self.tool.matchString(printername, patterns) : 
    707707                    printer = StoragePrinter(self, printername) 
     
    716716                        printer.PassThrough = 0 
    717717                    printer.uniqueMember = fields.get("uniqueMember", []) 
    718                     printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     718                    printer.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
    719719                    printer.Exists = True 
    720720                    printers.append(printer) 
     
    739739                    patdict[p] = None 
    740740            for (userid, fields) in result : 
    741                 username = self.databaseToUserCharset(fields.get("pykotaUserName", [""])[0] or fields.get(self.info["userrdn"], [""])[0]) 
     741                username = self.databaseToUnicode(fields.get("pykotaUserName", [""])[0] or fields.get(self.info["userrdn"], [""])[0]) 
    742742                if patdict.has_key(username) or self.tool.matchString(username, patterns) : 
    743743                    user = StorageUser(self, username) 
     
    745745                    user.Email = fields.get(self.info["usermail"], [None])[0] 
    746746                    user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    747                     user.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
    748                     uname = self.userCharsetToDatabase(username) 
     747                    user.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
     748                    uname = self.unicodeToDatabase(username) 
    749749                    result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \ 
    750750                                              (uname, self.info["balancerdn"], uname), \ 
     
    780780                                description = "" 
    781781                            else :     
    782                                 description = self.databaseToUserCharset(base64.decodestring(description)) 
     782                                description = self.databaseToUnicode(base64.decodestring(description)) 
    783783                            if amount.endswith(" #") :     
    784784                                amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think 
     
    806806                    patdict[p] = None 
    807807            for (groupid, fields) in result : 
    808                 groupname = self.databaseToUserCharset(fields.get("pykotaGroupName", [""])[0] or fields.get(self.info["grouprdn"], [""])[0]) 
     808                groupname = self.databaseToUnicode(fields.get("pykotaGroupName", [""])[0] or fields.get(self.info["grouprdn"], [""])[0]) 
    809809                if patdict.has_key(groupname) or self.tool.matchString(groupname, patterns) : 
    810810                    group = StorageGroup(self, groupname) 
    811811                    group.ident = groupid 
    812                     group.Name = fields.get("pykotaGroupName", [self.databaseToUserCharset(groupname)])[0]  
     812                    group.Name = fields.get("pykotaGroupName", [self.databaseToUnicode(groupname)])[0]  
    813813                    group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 
    814                     group.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     814                    group.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
    815815                    group.AccountBalance = 0.0 
    816816                    group.LifeTimePaid = 0.0 
     
    827827        """Returns the list of users who uses a given printer, along with their quotas.""" 
    828828        usersandquotas = [] 
    829         pname = self.userCharsetToDatabase(printer.Name) 
    830         names = [self.userCharsetToDatabase(n) for n in names] 
     829        pname = self.unicodeToDatabase(printer.Name) 
     830        names = [self.unicodeToDatabase(n) for n in names] 
    831831        if self.info["userquotabase"].lower() == "user" : 
    832832            base = self.info["userbase"] 
     
    839839        if result : 
    840840            for (userquotaid, fields) in result : 
    841                 user = self.getUser(self.databaseToUserCharset(fields.get("pykotaUserName")[0])) 
     841                user = self.getUser(self.databaseToUnicode(fields.get("pykotaUserName")[0])) 
    842842                userpquota = StorageUserPQuota(self, user, printer) 
    843843                userpquota.ident = userquotaid 
     
    872872        """Returns the list of groups which uses a given printer, along with their quotas.""" 
    873873        groupsandquotas = [] 
    874         pname = self.userCharsetToDatabase(printer.Name) 
    875         names = [self.userCharsetToDatabase(n) for n in names] 
     874        pname = self.unicodeToDatabase(printer.Name) 
     875        names = [self.unicodeToDatabase(n) for n in names] 
    876876        if self.info["groupquotabase"].lower() == "group" : 
    877877            base = self.info["groupbase"] 
     
    884884        if result : 
    885885            for (groupquotaid, fields) in result : 
    886                 group = self.getGroup(self.databaseToUserCharset(fields.get("pykotaGroupName")[0])) 
     886                group = self.getGroup(self.databaseToUnicode(fields.get("pykotaGroupName")[0])) 
    887887                grouppquota = self.getGroupPQuota(group, printer) 
    888888                groupsandquotas.append((group, grouppquota)) 
     
    895895        if oldentry.Exists : 
    896896            return oldentry # we return the existing entry 
    897         printername = self.userCharsetToDatabase(printer.Name) 
     897        printername = self.unicodeToDatabase(printer.Name) 
    898898        fields = { self.info["printerrdn"] : printername, 
    899899                   "objectClass" : ["pykotaObject", "pykotaPrinter"], 
     
    902902                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
    903903                   "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
    904                    "description" : self.userCharsetToDatabase(printer.Description or ""), 
     904                   "description" : self.unicodeToDatabase(printer.Description or ""), 
    905905                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
    906906                   "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), 
     
    916916        if oldentry.Exists : 
    917917            return oldentry # we return the existing entry 
    918         uname = self.userCharsetToDatabase(user.Name) 
     918        uname = self.unicodeToDatabase(user.Name) 
    919919        newfields = { 
    920920                       "pykotaUserName" : uname, 
    921921                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    922                        "description" : self.userCharsetToDatabase(user.Description or ""), 
     922                       "description" : self.unicodeToDatabase(user.Description or ""), 
    923923                       self.info["usermail"] : user.Email or "", 
    924924                    }    
     
    991991        if oldentry.Exists : 
    992992            return oldentry # we return the existing entry 
    993         gname = self.userCharsetToDatabase(group.Name) 
     993        gname = self.unicodeToDatabase(group.Name) 
    994994        newfields = {  
    995995                      "pykotaGroupName" : gname, 
    996996                      "pykotaLimitBy" : (group.LimitBy or "quota"), 
    997                       "description" : self.userCharsetToDatabase(group.Description or "") 
     997                      "description" : self.unicodeToDatabase(group.Description or "") 
    998998                    }  
    999999        mustadd = 1 
     
    10401040                if not fields.has_key(self.info["groupmembers"]) : 
    10411041                    fields[self.info["groupmembers"]] = [] 
    1042                 fields[self.info["groupmembers"]].append(self.userCharsetToDatabase(user.Name)) 
     1042                fields[self.info["groupmembers"]].append(self.unicodeToDatabase(user.Name)) 
    10431043                self.doModify(group.ident, fields) 
    10441044                group.Members.append(user) 
     
    10531053                    fields[self.info["groupmembers"]] = [] 
    10541054                try :     
    1055                     fields[self.info["groupmembers"]].remove(self.userCharsetToDatabase(user.Name)) 
     1055                    fields[self.info["groupmembers"]].remove(self.unicodeToDatabase(user.Name)) 
    10561056                except ValueError : 
    10571057                    pass # TODO : Strange, shouldn't it be there ? 
     
    10671067            return oldentry # we return the existing entry 
    10681068        uuid = self.genUUID() 
    1069         uname = self.userCharsetToDatabase(upq.User.Name) 
    1070         pname = self.userCharsetToDatabase(upq.Printer.Name) 
     1069        uname = self.unicodeToDatabase(upq.User.Name) 
     1070        pname = self.unicodeToDatabase(upq.Printer.Name) 
    10711071        fields = { "cn" : uuid, 
    10721072                   "objectClass" : ["pykotaObject", "pykotaUserPQuota"], 
     
    10951095            return oldentry # we return the existing entry 
    10961096        uuid = self.genUUID() 
    1097         gname = self.userCharsetToDatabase(gpq.Group.Name) 
    1098         pname = self.userCharsetToDatabase(gpq.Printer.Name) 
     1097        gname = self.unicodeToDatabase(gpq.Group.Name) 
     1098        pname = self.unicodeToDatabase(gpq.Printer.Name) 
    10991099        fields = { "cn" : uuid, 
    11001100                   "objectClass" : ["pykotaObject", "pykotaGroupPQuota"], 
     
    11161116                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
    11171117                   "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
    1118                    "description" : self.userCharsetToDatabase(printer.Description or ""), 
     1118                   "description" : self.unicodeToDatabase(printer.Description or ""), 
    11191119                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
    11201120                   "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), 
     
    11261126        newfields = { 
    11271127                       "pykotaLimitBy" : (user.LimitBy or "quota"), 
    1128                        "description" : self.userCharsetToDatabase(user.Description or ""),  
     1128                       "description" : self.unicodeToDatabase(user.Description or ""),  
    11291129                       self.info["usermail"] : user.Email or "", 
    11301130                    }    
     
    11411141        newfields = { 
    11421142                       "pykotaLimitBy" : (group.LimitBy or "quota"), 
    1143                        "description" : self.userCharsetToDatabase(group.Description or ""),  
     1143                       "description" : self.unicodeToDatabase(group.Description or ""),  
    11441144                    }    
    11451145        self.doModify(group.ident, newfields) 
     
    11781178        payments = [] 
    11791179        for payment in user.Payments : 
    1180             payments.append("%s # %s # %s" % (payment[0], str(payment[1]), base64.encodestring(self.userCharsetToDatabase(payment[2])).strip())) 
    1181         payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), base64.encodestring(self.userCharsetToDatabase(comment)).strip())) 
     1180            payments.append("%s # %s # %s" % (payment[0], str(payment[1]), base64.encodestring(self.unicodeToDatabase(payment[2])).strip())) 
     1181        payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), base64.encodestring(self.unicodeToDatabase(comment)).strip())) 
    11821182        fields = { 
    11831183                   "pykotaPayments" : payments, 
     
    11951195    def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None, precomputedsize=None, precomputedprice=None) : 
    11961196        """Adds a job in a printer's history.""" 
    1197         uname = self.userCharsetToDatabase(user.Name) 
    1198         pname = self.userCharsetToDatabase(printer.Name) 
     1197        uname = self.unicodeToDatabase(user.Name) 
     1198        pname = self.unicodeToDatabase(printer.Name) 
    11991199        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    12001200            uuid = self.genUUID() 
     
    12141214                   "pykotaPrinterPageCounter" : str(pagecounter), 
    12151215                   "pykotaAction" : action, 
    1216                    "pykotaFileName" : ((filename is None) and "None") or self.userCharsetToDatabase(filename),  
    1217                    "pykotaTitle" : ((title is None) and "None") or self.userCharsetToDatabase(title),  
     1216                   "pykotaFileName" : ((filename is None) and "None") or self.unicodeToDatabase(filename),  
     1217                   "pykotaTitle" : ((title is None) and "None") or self.unicodeToDatabase(title),  
    12181218                   "pykotaCopies" : str(copies),  
    1219                    "pykotaOptions" : ((options is None) and "None") or self.userCharsetToDatabase(options),  
     1219                   "pykotaOptions" : ((options is None) and "None") or self.unicodeToDatabase(options),  
    12201220                   "pykotaHostName" : str(clienthost),  
    12211221                   "pykotaJobSizeBytes" : str(jobsizebytes), 
    12221222                   "pykotaMD5Sum" : str(jobmd5sum), 
    12231223                   "pykotaPages" : jobpages,            # don't add this attribute if it is not set, so no string conversion 
    1224                    "pykotaBillingCode" : self.userCharsetToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion 
     1224                   "pykotaBillingCode" : self.unicodeToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion 
    12251225                   "pykotaPrecomputedJobSize" : str(precomputedsize), 
    12261226                   "pykotaPrecomputedJobPrice" : str(precomputedprice), 
     
    13141314        where = [] 
    13151315        if user is not None : 
    1316             where.append("(pykotaUserName=%s)" % self.userCharsetToDatabase(user.Name)) 
     1316            where.append("(pykotaUserName=%s)" % self.unicodeToDatabase(user.Name)) 
    13171317        if printer is not None : 
    1318             where.append("(pykotaPrinterName=%s)" % self.userCharsetToDatabase(printer.Name)) 
     1318            where.append("(pykotaPrinterName=%s)" % self.unicodeToDatabase(printer.Name)) 
    13191319        if hostname is not None : 
    13201320            where.append("(pykotaHostName=%s)" % hostname) 
    13211321        if billingcode is not None : 
    1322             where.append("(pykotaBillingCode=%s)" % self.userCharsetToDatabase(billingcode)) 
     1322            where.append("(pykotaBillingCode=%s)" % self.unicodeToDatabase(billingcode)) 
    13231323        if jobid is not None : 
    1324             where.append("(pykotaJobId=%s)" % jobid) # TODO : jobid is text, so self.userCharsetToDatabase(jobid) but do all of them as well. 
     1324            where.append("(pykotaJobId=%s)" % jobid) # TODO : jobid is text, so self.unicodeToDatabase(jobid) but do all of them as well. 
    13251325        if where :     
    13261326            where = "(&%s)" % "".join([precond] + where) 
     
    13631363                    job.JobPrice = None 
    13641364                job.JobAction = fields.get("pykotaAction", [""])[0] 
    1365                 job.JobFileName = self.databaseToUserCharset(fields.get("pykotaFileName", [""])[0])  
    1366                 job.JobTitle = self.databaseToUserCharset(fields.get("pykotaTitle", [""])[0])  
     1365                job.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0])  
     1366                job.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0])  
    13671367                job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 
    1368                 job.JobOptions = self.databaseToUserCharset(fields.get("pykotaOptions", [""])[0])  
     1368                job.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0])  
    13691369                job.JobHostName = fields.get("pykotaHostName", [""])[0] 
    13701370                job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 
    1371                 job.JobBillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [None])[0]) 
     1371                job.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 
    13721372                job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
    13731373                job.JobPages = fields.get("pykotaPages", [""])[0] 
     
    13891389                   ((end is None) and (job.JobDate >= start)) or \ 
    13901390                   ((job.JobDate >= start) and (job.JobDate <= end)) : 
    1391                     job.UserName = self.databaseToUserCharset(fields.get("pykotaUserName")[0]) 
    1392                     job.PrinterName = self.databaseToUserCharset(fields.get("pykotaPrinterName")[0]) 
     1391                    job.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0]) 
     1392                    job.PrinterName = self.databaseToUnicode(fields.get("pykotaPrinterName")[0]) 
    13931393                    job.Exists = True 
    13941394                    jobs.append(job) 
     
    14001400    def deleteUser(self, user) :     
    14011401        """Completely deletes an user from the Quota Storage.""" 
    1402         uname = self.userCharsetToDatabase(user.Name) 
     1402        uname = self.unicodeToDatabase(user.Name) 
    14031403        todelete = []     
    14041404        result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s))" % uname, base=self.info["jobbase"]) 
     
    14181418            # if last job of current printer was printed by the user 
    14191419            # to delete, we also need to delete the printer's last job entry. 
    1420             printer = self.getPrinter(self.databaseToUserCharset(fields["pykotaPrinterName"][0])) 
     1420            printer = self.getPrinter(self.databaseToUnicode(fields["pykotaPrinterName"][0])) 
    14211421            if printer.LastJob.UserName == user.Name : 
    14221422                todelete.append(printer.LastJob.lastjobident) 
     
    14531453    def deleteGroup(self, group) :     
    14541454        """Completely deletes a group from the Quota Storage.""" 
    1455         gname = self.userCharsetToDatabase(group.Name) 
     1455        gname = self.unicodeToDatabase(group.Name) 
    14561456        if self.info["groupquotabase"].lower() == "group" : 
    14571457            base = self.info["groupbase"] 
     
    15241524    def deleteUserPQuota(self, upquota) :     
    15251525        """Completely deletes an user print quota entry from the database.""" 
    1526         uname = self.userCharsetToDatabase(upquota.User.Name) 
    1527         pname = self.userCharsetToDatabase(upquota.Printer.Name) 
     1526        uname = self.unicodeToDatabase(upquota.User.Name) 
     1527        pname = self.unicodeToDatabase(upquota.Printer.Name) 
    15281528        result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s)(pykotaPrinterName=%s))" \ 
    15291529                                   % (uname, pname), \ 
     
    15411541    def deletePrinter(self, printer) :     
    15421542        """Completely deletes a printer from the Quota Storage.""" 
    1543         pname = self.userCharsetToDatabase(printer.Name) 
     1543        pname = self.unicodeToDatabase(printer.Name) 
    15441544        result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % pname, base=self.info["lastjobbase"]) 
    15451545        for (ident, fields) in result : 
     
    17641764        """Extracts billing code information given its label : returns first matching billing code.""" 
    17651765        code = StorageBillingCode(self, label) 
    1766         ulabel = self.userCharsetToDatabase(label) 
     1766        ulabel = self.unicodeToDatabase(label) 
    17671767        result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % \ 
    17681768                                  ulabel, \ 
     
    17721772            fields = result[0][1]       # take only first matching code, ignore the rest 
    17731773            code.ident = result[0][0] 
    1774             code.BillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [ulabel])[0]) 
     1774            code.BillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [ulabel])[0]) 
    17751775            code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 
    17761776            code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) 
    1777             code.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     1777            code.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
    17781778            code.Exists = True 
    17791779        return code     
     
    17881788        fields = { "objectClass" : ["pykotaObject", "pykotaBilling"], 
    17891789                   "cn" : uuid, 
    1790                    "pykotaBillingCode" : self.userCharsetToDatabase(bcode.BillingCode), 
     1790                   "pykotaBillingCode" : self.unicodeToDatabase(bcode.BillingCode), 
    17911791                   "pykotaPageCounter" : str(bcode.PageCounter or 0), 
    17921792                   "pykotaBalance" : str(bcode.Balance or 0.0), 
    1793                    "description" : self.userCharsetToDatabase(bcode.Description or ""),  
     1793                   "description" : self.unicodeToDatabase(bcode.Description or ""),  
    17941794                 }  
    17951795        self.doAdd(dn, fields) 
     
    18001800        """Sets the new description for a billing code.""" 
    18011801        fields = { 
    1802                    "description" : self.userCharsetToDatabase(bcode.Description or ""),  
     1802                   "description" : self.unicodeToDatabase(bcode.Description or ""),  
    18031803                   "pykotaPageCounter" : str(bcode.PageCounter or 0), 
    18041804                   "pykotaBalance" : str(bcode.Balance or 0.0), 
     
    18221822                    patdict[p] = None 
    18231823            for (codeid, fields) in result : 
    1824                 codename = self.databaseToUserCharset(fields.get("pykotaBillingCode", [""])[0]) 
     1824                codename = self.databaseToUnicode(fields.get("pykotaBillingCode", [""])[0]) 
    18251825                if patdict.has_key(codename) or self.tool.matchString(codename, patterns) : 
    18261826                    code = StorageBillingCode(self, codename) 
     
    18281828                    code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 
    18291829                    code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) 
    1830                     code.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     1830                    code.Description = self.databaseToUnicode(fields.get("description", [""])[0])  
    18311831                    code.Exists = True 
    18321832                    codes.append(code) 
  • pykota/trunk/pykota/storages/pgstorage.py

    r3288 r3291  
    154154                    field = fields[j] 
    155155                    if type(field) == StringType : 
    156                         fields[j] = self.databaseToUserCharset(field)  
     156                        fields[j] = self.databaseToUnicode(field)  
    157157                entries[i] = tuple(fields)     
    158158            return entries 
  • pykota/trunk/pykota/storages/sql.py

    r3275 r3291  
    3636        user.LifeTimePaid = record.get("lifetimepaid") 
    3737        user.Email = record.get("email") 
    38         user.Description = self.databaseToUserCharset(record.get("description")) 
     38        user.Description = self.databaseToUnicode(record.get("description")) 
    3939        user.OverCharge = record.get("overcharge", 1.0) 
    4040        user.Exists = True 
     
    4848        group.AccountBalance = record.get("balance") 
    4949        group.LifeTimePaid = record.get("lifetimepaid") 
    50         group.Description = self.databaseToUserCharset(record.get("description")) 
     50        group.Description = self.databaseToUnicode(record.get("description")) 
    5151        group.Exists = True 
    5252        return group 
     
    6464        else : 
    6565            printer.PassThrough = False 
    66         printer.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ? 
     66        printer.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ? 
    6767        printer.Exists = True 
    6868        return printer 
     
    7676        job.JobPrice = record.get("jobprice") 
    7777        job.JobAction = record.get("action") 
    78         job.JobFileName = self.databaseToUserCharset(record.get("filename") or "")  
    79         job.JobTitle = self.databaseToUserCharset(record.get("title") or "")  
     78        job.JobFileName = self.databaseToUnicode(record.get("filename") or "")  
     79        job.JobTitle = self.databaseToUnicode(record.get("title") or "")  
    8080        job.JobCopies = record.get("copies") 
    81         job.JobOptions = self.databaseToUserCharset(record.get("options") or "")  
     81        job.JobOptions = self.databaseToUnicode(record.get("options") or "")  
    8282        job.JobDate = record.get("jobdate") 
    8383        job.JobHostName = record.get("hostname") 
     
    8585        job.JobMD5Sum = record.get("md5sum") 
    8686        job.JobPages = record.get("pages") 
    87         job.JobBillingCode = self.databaseToUserCharset(record.get("billingcode") or "") 
     87        job.JobBillingCode = self.databaseToUnicode(record.get("billingcode") or "") 
    8888        job.PrecomputedJobSize = record.get("precomputedjobsize") 
    8989        job.PrecomputedJobPrice = record.get("precomputedjobprice") 
    90         job.UserName = self.databaseToUserCharset(record.get("username")) 
    91         job.PrinterName = self.databaseToUserCharset(record.get("printername")) 
     90        job.UserName = self.databaseToUnicode(record.get("username")) 
     91        job.PrinterName = self.databaseToUnicode(record.get("printername")) 
    9292        if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" : 
    9393            (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
     
    138138        code = StorageBillingCode(self, billingcode) 
    139139        code.ident = record.get("id") 
    140         code.Description = self.databaseToUserCharset(record.get("description") or "") # TODO : is 'or ""' still needed ? 
     140        code.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ? 
    141141        code.Balance = record.get("balance") or 0.0 
    142142        code.PageCounter = record.get("pagecounter") or 0 
     
    149149            expressions = [] 
    150150            for (k, v) in only.items() : 
    151                 expressions.append("%s=%s" % (k, self.doQuote(self.userCharsetToDatabase(v)))) 
     151                expressions.append("%s=%s" % (k, self.doQuote(self.unicodeToDatabase(v)))) 
    152152            return " AND ".join(expressions)      
    153153        return ""         
     
    299299                self.tool.printInfo("Object %s has no %s attribute !" % (repr(record), attribute), "error") 
    300300            else : 
    301                 attrval = self.databaseToUserCharset(attrval) 
     301                attrval = self.databaseToUnicode(attrval) 
    302302                if patterns : 
    303303                    if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) : 
     
    351351        """Extracts user information given its name.""" 
    352352        result = self.doSearch("SELECT * FROM users WHERE username=%s"\ 
    353                       % self.doQuote(self.userCharsetToDatabase(username))) 
     353                      % self.doQuote(self.unicodeToDatabase(username))) 
    354354        if result : 
    355355            return self.storageUserFromRecord(username, result[0]) 
     
    360360        """Extracts group information given its name.""" 
    361361        result = self.doSearch("SELECT groups.*,COALESCE(SUM(balance), 0.0) AS balance, COALESCE(SUM(lifetimepaid), 0.0) AS lifetimepaid FROM groups LEFT OUTER JOIN users ON users.id IN (SELECT userid FROM groupsmembers WHERE groupid=groups.id) WHERE groupname=%s GROUP BY groups.id,groups.groupname,groups.limitby,groups.description" \ 
    362                       % self.doQuote(self.userCharsetToDatabase(groupname))) 
     362                      % self.doQuote(self.unicodeToDatabase(groupname))) 
    363363        if result : 
    364364            return self.storageGroupFromRecord(groupname, result[0]) 
     
    369369        """Extracts printer information given its name.""" 
    370370        result = self.doSearch("SELECT * FROM printers WHERE printername=%s" \ 
    371                       % self.doQuote(self.userCharsetToDatabase(printername))) 
     371                      % self.doQuote(self.unicodeToDatabase(printername))) 
    372372        if result : 
    373373            return self.storagePrinterFromRecord(printername, result[0]) 
     
    378378        """Extracts a billing code information given its name.""" 
    379379        result = self.doSearch("SELECT * FROM billingcodes WHERE billingcode=%s" \ 
    380                       % self.doQuote(self.userCharsetToDatabase(label))) 
     380                      % self.doQuote(self.unicodeToDatabase(label))) 
    381381        if result : 
    382382            return self.storageBillingCodeFromRecord(label, result[0]) 
     
    416416        if result : 
    417417            for record in result : 
    418                 user = self.storageUserFromRecord(self.databaseToUserCharset(record.get("username")), \ 
     418                user = self.storageUserFromRecord(self.databaseToUnicode(record.get("username")), \ 
    419419                                                  record) 
    420420                groupmembers.append(user) 
     
    428428        if result : 
    429429            for record in result : 
    430                 groups.append(self.getGroup(self.databaseToUserCharset(record.get("groupname")))) 
     430                groups.append(self.getGroup(self.databaseToUnicode(record.get("groupname")))) 
    431431        return groups         
    432432         
     
    438438            for record in result : 
    439439                if record["groupid"] != printer.ident : # in case of integrity violation 
    440                     parentprinter = self.getPrinter(self.databaseToUserCharset(record.get("printername"))) 
     440                    parentprinter = self.getPrinter(self.databaseToUnicode(record.get("printername"))) 
    441441                    if parentprinter.Exists : 
    442442                        pgroups.append(parentprinter) 
     
    460460                    patdict[p] = None 
    461461            for record in result : 
    462                 pname = self.databaseToUserCharset(record["printername"]) 
     462                pname = self.databaseToUnicode(record["printername"]) 
    463463                if patdict.has_key(pname) or self.tool.matchString(pname, patterns) : 
    464464                    printer = self.storagePrinterFromRecord(pname, record) 
     
    484484                    patdict[p] = None 
    485485            for record in result : 
    486                 uname = self.databaseToUserCharset(record["username"]) 
     486                uname = self.databaseToUnicode(record["username"]) 
    487487                if patdict.has_key(uname) or self.tool.matchString(uname, patterns) : 
    488488                    user = self.storageUserFromRecord(uname, record) 
     
    508508                    patdict[p] = None 
    509509            for record in result : 
    510                 gname = self.databaseToUserCharset(record["groupname"]) 
     510                gname = self.databaseToUnicode(record["groupname"]) 
    511511                if patdict.has_key(gname) or self.tool.matchString(gname, patterns) : 
    512512                    group = self.storageGroupFromRecord(gname, record) 
     
    529529                    patdict[p] = None 
    530530            for record in result : 
    531                 codename = self.databaseToUserCharset(record["billingcode"]) 
     531                codename = self.databaseToUnicode(record["billingcode"]) 
    532532                if patdict.has_key(codename) or self.tool.matchString(codename, patterns) : 
    533533                    code = self.storageBillingCodeFromRecord(codename, record) 
     
    542542        if result : 
    543543            for record in result : 
    544                 uname = self.databaseToUserCharset(record.get("username")) 
     544                uname = self.databaseToUnicode(record.get("username")) 
    545545                if self.tool.matchString(uname, names) : 
    546546                    user = self.storageUserFromRecord(uname, record) 
     
    557557        if result : 
    558558            for record in result : 
    559                 gname = self.databaseToUserCharset(record.get("groupname")) 
     559                gname = self.databaseToUnicode(record.get("groupname")) 
    560560                if self.tool.matchString(gname, names) : 
    561561                    group = self.getGroup(gname) 
     
    570570            return oldentry 
    571571        self.doModify("INSERT INTO printers (printername, passthrough, maxjobsize, description, priceperpage, priceperjob) VALUES (%s, %s, %s, %s, %s, %s)" \ 
    572                           % (self.doQuote(self.userCharsetToDatabase(printer.Name)), \ 
     572                          % (self.doQuote(self.unicodeToDatabase(printer.Name)), \ 
    573573                             self.doQuote((printer.PassThrough and "t") or "f"), \ 
    574574                             self.doQuote(printer.MaxJobSize or 0), \ 
    575                              self.doQuote(self.userCharsetToDatabase(printer.Description)), \ 
     575                             self.doQuote(self.unicodeToDatabase(printer.Description)), \ 
    576576                             self.doQuote(printer.PricePerPage or 0.0), \ 
    577577                             self.doQuote(printer.PricePerJob or 0.0))) 
     
    585585            return oldentry 
    586586        self.doModify("INSERT INTO billingcodes (billingcode, balance, pagecounter, description) VALUES (%s, %s, %s, %s)" \ 
    587                            % (self.doQuote(self.userCharsetToDatabase(bcode.BillingCode)),  
     587                           % (self.doQuote(self.unicodeToDatabase(bcode.BillingCode)),  
    588588                              self.doQuote(bcode.Balance or 0.0), \ 
    589589                              self.doQuote(bcode.PageCounter or 0), \ 
    590                               self.doQuote(self.userCharsetToDatabase(bcode.Description)))) 
     590                              self.doQuote(self.unicodeToDatabase(bcode.Description)))) 
    591591        bcode.isDirty = False 
    592592        return None # the entry created doesn't need further modification 
     
    598598            return oldentry 
    599599        self.doModify("INSERT INTO users (username, limitby, balance, lifetimepaid, email, overcharge, description) VALUES (%s, %s, %s, %s, %s, %s, %s)" % \ 
    600                                      (self.doQuote(self.userCharsetToDatabase(user.Name)), \ 
     600                                     (self.doQuote(self.unicodeToDatabase(user.Name)), \ 
    601601                                      self.doQuote(user.LimitBy or 'quota'), \ 
    602602                                      self.doQuote(user.AccountBalance or 0.0), \ 
     
    604604                                      self.doQuote(user.Email), \ 
    605605                                      self.doQuote(user.OverCharge), \ 
    606                                       self.doQuote(self.userCharsetToDatabase(user.Description)))) 
     606                                      self.doQuote(self.unicodeToDatabase(user.Description)))) 
    607607        if user.PaymentsBacklog : 
    608608            for (value, comment) in user.PaymentsBacklog : 
     
    618618            return oldentry 
    619619        self.doModify("INSERT INTO groups (groupname, limitby, description) VALUES (%s, %s, %s)" % \ 
    620                               (self.doQuote(self.userCharsetToDatabase(group.Name)), \ 
     620                              (self.doQuote(self.unicodeToDatabase(group.Name)), \ 
    621621                               self.doQuote(group.LimitBy or "quota"), \ 
    622                                self.doQuote(self.userCharsetToDatabase(group.Description)))) 
     622                               self.doQuote(self.unicodeToDatabase(group.Description)))) 
    623623        group.isDirty = False 
    624624        return None # the entry created doesn't need further modification 
     
    677677                              % (self.doQuote((printer.PassThrough and "t") or "f"), \ 
    678678                                 self.doQuote(printer.MaxJobSize or 0), \ 
    679                                  self.doQuote(self.userCharsetToDatabase(printer.Description)), \ 
     679                                 self.doQuote(self.unicodeToDatabase(printer.Description)), \ 
    680680                                 self.doQuote(printer.PricePerPage or 0.0), \ 
    681681                                 self.doQuote(printer.PricePerJob or 0.0), \ 
     
    690690                                  self.doQuote(user.Email), \ 
    691691                                  self.doQuote(user.OverCharge), \ 
    692                                   self.doQuote(self.userCharsetToDatabase(user.Description)), \ 
     692                                  self.doQuote(self.unicodeToDatabase(user.Description)), \ 
    693693                                  self.doQuote(user.ident))) 
    694694                                   
     
    697697        self.doModify("UPDATE groups SET limitby=%s, description=%s WHERE id=%s" \ 
    698698                               % (self.doQuote(group.LimitBy or 'quota'), \ 
    699                                   self.doQuote(self.userCharsetToDatabase(group.Description)), \ 
     699                                  self.doQuote(self.unicodeToDatabase(group.Description)), \ 
    700700                                  self.doQuote(group.ident))) 
    701701         
     
    717717                            % (self.doQuote(bcode.Balance or 0.0), \ 
    718718                               self.doQuote(bcode.PageCounter or 0), \ 
    719                                self.doQuote(self.userCharsetToDatabase(bcode.Description)), \ 
     719                               self.doQuote(self.unicodeToDatabase(bcode.Description)), \ 
    720720                               self.doQuote(bcode.ident))) 
    721721        
     
    735735        """Adds a new payment to the payments history.""" 
    736736        if user.ident is not None : 
    737             self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment)))) 
     737            self.doModify("INSERT INTO payments (userid, amount, description) VALUES (%s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment)))) 
    738738        else :     
    739             self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.userCharsetToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.userCharsetToDatabase(comment)))) 
     739            self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.unicodeToDatabase(user.Name)), self.doQuote(amount), self.doQuote(self.unicodeToDatabase(comment)))) 
    740740         
    741741    def writeLastJobSize(self, lastjob, jobsize, jobprice) :         
     
    748748            # For legal reasons, we want to hide the title, filename and options 
    749749            title = filename = options = "hidden" 
    750         filename = self.userCharsetToDatabase(filename) 
    751         title = self.userCharsetToDatabase(title) 
    752         options = self.userCharsetToDatabase(options) 
    753         jobbilling = self.userCharsetToDatabase(jobbilling) 
     750        filename = self.unicodeToDatabase(filename) 
     751        title = self.unicodeToDatabase(title) 
     752        options = self.unicodeToDatabase(options) 
     753        jobbilling = self.unicodeToDatabase(jobbilling) 
    754754        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    755755            if jobsize is not None : 
     
    814814            where.append("hostname=%s" % self.doQuote(hostname)) 
    815815        if billingcode is not None :     
    816             where.append("billingcode=%s" % self.doQuote(self.userCharsetToDatabase(billingcode))) 
     816            where.append("billingcode=%s" % self.doQuote(self.unicodeToDatabase(billingcode))) 
    817817        if jobid is not None :     
    818             where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.userCharsetToDatabase(jobid) but do all of them as well. 
     818            where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.unicodeToDatabase(jobid) but do all of them as well. 
    819819        if start is not None :     
    820820            where.append("jobdate>=%s" % self.doQuote(start))