Changeset 3291
- Timestamp:
- 01/13/08 01:22:35 (17 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/dumper.py
r3288 r3291 244 244 line = [] 245 245 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) 250 255 try : 251 256 self.outfile.write("%s\n" % separator.join(line)) … … 313 318 x.entry() 314 319 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) 326 334 x._pop() 327 335 x._pop() -
pykota/trunk/pykota/storage.py
r3288 r3291 728 728 return gpquotas 729 729 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 738 744 def cleanDates(self, startdate, enddate) : 739 745 """Clean the dates to create a correct filter.""" -
pykota/trunk/pykota/storages/ldapstorage.py
r3288 r3291 303 303 self.tool.printInfo("Object %s has no %s attribute !" % (dn, attribute), "error") 304 304 else : 305 attrval = self.databaseToU serCharset(attrval)305 attrval = self.databaseToUnicode(attrval) 306 306 if patterns : 307 307 if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) : … … 318 318 result = self.doSearch(ldapfilter, ["pykotaBillingCode"], base=self.info["billingcodebase"]) 319 319 if result : 320 return [self.databaseToU serCharset(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)]320 return [self.databaseToUnicode(bc) for bc in self.filterNames(result, "pykotaBillingCode", billingcode)] 321 321 else : 322 322 return [] … … 351 351 def getUserNbJobsFromHistory(self, user) : 352 352 """Returns the number of jobs the user has in history.""" 353 result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.u serCharsetToDatabase(user.Name), None, base=self.info["jobbase"])353 result = self.doSearch("(&(pykotaUserName=%s)(objectClass=pykotaJob))" % self.unicodeToDatabase(user.Name), None, base=self.info["jobbase"]) 354 354 return len(result) 355 355 … … 357 357 """Extracts user information given its name.""" 358 358 user = StorageUser(self, username) 359 username = self.u serCharsetToDatabase(username)359 username = self.unicodeToDatabase(username) 360 360 result = self.doSearch("(&(objectClass=pykotaAccount)(|(pykotaUserName=%s)(%s=%s)))" % (username, self.info["userrdn"], username), ["pykotaUserName", "pykotaLimitBy", self.info["usermail"], "description"], base=self.info["userbase"]) 361 361 if result : 362 362 fields = result[0][1] 363 363 user.ident = result[0][0] 364 user.Description = self.databaseToU serCharset(fields.get("description", [None])[0])364 user.Description = self.databaseToUnicode(fields.get("description", [None])[0]) 365 365 user.Email = fields.get(self.info["usermail"], [None])[0] 366 366 user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] … … 395 395 description = "" 396 396 else : 397 description = self.databaseToU serCharset(base64.decodestring(description))397 description = self.databaseToUnicode(base64.decodestring(description)) 398 398 if amount.endswith(" #") : 399 399 amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think … … 405 405 """Extracts group information given its name.""" 406 406 group = StorageGroup(self, groupname) 407 groupname = self.u serCharsetToDatabase(groupname)407 groupname = self.unicodeToDatabase(groupname) 408 408 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % (groupname, self.info["grouprdn"], groupname), ["pykotaGroupName", "pykotaLimitBy", "description"], base=self.info["groupbase"]) 409 409 if result : 410 410 fields = result[0][1] 411 411 group.ident = result[0][0] 412 group.Name = fields.get("pykotaGroupName", [self.databaseToU serCharset(groupname)])[0]413 group.Description = self.databaseToU serCharset(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]) 414 414 group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 415 415 group.AccountBalance = 0.0 … … 425 425 """Extracts printer information given its name : returns first matching printer.""" 426 426 printer = StoragePrinter(self, printername) 427 printername = self.u serCharsetToDatabase(printername)427 printername = self.unicodeToDatabase(printername) 428 428 result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" \ 429 429 % (printername, self.info["printerrdn"], printername), \ … … 435 435 fields = result[0][1] # take only first matching printer, ignore the rest 436 436 printer.ident = result[0][0] 437 printer.Name = fields.get("pykotaPrinterName", [self.databaseToU serCharset(printername)])[0]437 printer.Name = fields.get("pykotaPrinterName", [self.databaseToUnicode(printername)])[0] 438 438 printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 439 439 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) … … 445 445 printer.PassThrough = 0 446 446 printer.uniqueMember = fields.get("uniqueMember", []) 447 printer.Description = self.databaseToU serCharset(fields.get("description", [""])[0])447 printer.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 448 448 printer.Exists = True 449 449 return printer … … 458 458 base = self.info["userquotabase"] 459 459 result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s)(pykotaPrinterName=%s))" % \ 460 (self.u serCharsetToDatabase(user.Name), self.userCharsetToDatabase(printer.Name)), \460 (self.unicodeToDatabase(user.Name), self.unicodeToDatabase(printer.Name)), \ 461 461 ["pykotaPageCounter", "pykotaLifePageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaWarnCount", "pykotaMaxJobSize"], \ 462 462 base=base) … … 503 503 base = self.info["groupquotabase"] 504 504 result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \ 505 (self.u serCharsetToDatabase(group.Name), self.userCharsetToDatabase(printer.Name)), \505 (self.unicodeToDatabase(group.Name), self.unicodeToDatabase(printer.Name)), \ 506 506 ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaMaxJobSize"], \ 507 507 base=base) … … 535 535 grouppquota.PageCounter = 0 536 536 grouppquota.LifePageCounter = 0 537 usernamesfilter = "".join(["(pykotaUserName=%s)" % self.u serCharsetToDatabase(member.Name) for member in self.getGroupMembers(group)])537 usernamesfilter = "".join(["(pykotaUserName=%s)" % self.unicodeToDatabase(member.Name) for member in self.getGroupMembers(group)]) 538 538 if usernamesfilter : 539 539 usernamesfilter = "(|%s)" % usernamesfilter … … 543 543 base = self.info["userquotabase"] 544 544 result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaPrinterName=%s)%s)" % \ 545 (self.u serCharsetToDatabase(printer.Name), usernamesfilter), \545 (self.unicodeToDatabase(printer.Name), usernamesfilter), \ 546 546 ["pykotaPageCounter", "pykotaLifePageCounter"], base=base) 547 547 if result : … … 555 555 """Extracts a printer's last job information.""" 556 556 lastjob = StorageLastJob(self, printer) 557 pname = self.u serCharsetToDatabase(printer.Name)557 pname = self.unicodeToDatabase(printer.Name) 558 558 result = self.doSearch("(&(objectClass=pykotaLastjob)(|(pykotaPrinterName=%s)(%s=%s)))" % \ 559 559 (pname, self.info["printerrdn"], pname), \ … … 591 591 lastjob.ident = result[0][0] 592 592 lastjob.JobId = fields.get("pykotaJobId")[0] 593 lastjob.UserName = self.databaseToU serCharset(fields.get("pykotaUserName")[0])593 lastjob.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0]) 594 594 lastjob.PrinterPageCounter = int(fields.get("pykotaPrinterPageCounter", [0])[0]) 595 595 try : … … 602 602 lastjob.JobPrice = None 603 603 lastjob.JobAction = fields.get("pykotaAction", [""])[0] 604 lastjob.JobFileName = self.databaseToU serCharset(fields.get("pykotaFileName", [""])[0])605 lastjob.JobTitle = self.databaseToU serCharset(fields.get("pykotaTitle", [""])[0])604 lastjob.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0]) 605 lastjob.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0]) 606 606 lastjob.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 607 lastjob.JobOptions = self.databaseToU serCharset(fields.get("pykotaOptions", [""])[0])607 lastjob.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0]) 608 608 lastjob.JobHostName = fields.get("pykotaHostName", [""])[0] 609 609 lastjob.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 610 lastjob.JobBillingCode = self.databaseToU serCharset(fields.get("pykotaBillingCode", [None])[0])610 lastjob.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 611 611 lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 612 612 lastjob.JobPages = fields.get("pykotaPages", [""])[0] … … 630 630 """Returns the group's members list.""" 631 631 groupmembers = [] 632 gname = self.u serCharsetToDatabase(group.Name)632 gname = self.unicodeToDatabase(group.Name) 633 633 result = self.doSearch("(&(objectClass=pykotaGroup)(|(pykotaGroupName=%s)(%s=%s)))" % \ 634 634 (gname, self.info["grouprdn"], gname), \ … … 637 637 if result : 638 638 for username in result[0][1].get(self.info["groupmembers"], []) : 639 groupmembers.append(self.getUser(self.databaseToU serCharset(username)))639 groupmembers.append(self.getUser(self.databaseToUnicode(username))) 640 640 return groupmembers 641 641 … … 643 643 """Returns the user's groups list.""" 644 644 groups = [] 645 uname = self.u serCharsetToDatabase(user.Name)645 uname = self.unicodeToDatabase(user.Name) 646 646 result = self.doSearch("(&(objectClass=pykotaGroup)(%s=%s))" % \ 647 647 (self.info["groupmembers"], uname), \ … … 650 650 if result : 651 651 for (groupid, fields) in result : 652 groupname = self.databaseToU serCharset((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]) 653 653 group = self.getFromCache("GROUPS", groupname) 654 654 if group is None : … … 681 681 for (printerid, fields) in result : 682 682 if printerid != printer.ident : # In case of integrity violation. 683 parentprinter = self.getPrinter(self.databaseToU serCharset(fields.get("pykotaPrinterName")[0]))683 parentprinter = self.getPrinter(self.databaseToUnicode(fields.get("pykotaPrinterName")[0])) 684 684 if parentprinter.Exists : 685 685 pgroups.append(parentprinter) … … 703 703 patdict[p] = None 704 704 for (printerid, fields) in result : 705 printername = self.databaseToU serCharset(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]) 706 706 if patdict.has_key(printername) or self.tool.matchString(printername, patterns) : 707 707 printer = StoragePrinter(self, printername) … … 716 716 printer.PassThrough = 0 717 717 printer.uniqueMember = fields.get("uniqueMember", []) 718 printer.Description = self.databaseToU serCharset(fields.get("description", [""])[0])718 printer.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 719 719 printer.Exists = True 720 720 printers.append(printer) … … 739 739 patdict[p] = None 740 740 for (userid, fields) in result : 741 username = self.databaseToU serCharset(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]) 742 742 if patdict.has_key(username) or self.tool.matchString(username, patterns) : 743 743 user = StorageUser(self, username) … … 745 745 user.Email = fields.get(self.info["usermail"], [None])[0] 746 746 user.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 747 user.Description = self.databaseToU serCharset(fields.get("description", [""])[0])748 uname = self.u serCharsetToDatabase(username)747 user.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 748 uname = self.unicodeToDatabase(username) 749 749 result = self.doSearch("(&(objectClass=pykotaAccountBalance)(|(pykotaUserName=%s)(%s=%s)))" % \ 750 750 (uname, self.info["balancerdn"], uname), \ … … 780 780 description = "" 781 781 else : 782 description = self.databaseToU serCharset(base64.decodestring(description))782 description = self.databaseToUnicode(base64.decodestring(description)) 783 783 if amount.endswith(" #") : 784 784 amount = amount[:-2] # TODO : should be catched earlier, the bug is above I think … … 806 806 patdict[p] = None 807 807 for (groupid, fields) in result : 808 groupname = self.databaseToU serCharset(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]) 809 809 if patdict.has_key(groupname) or self.tool.matchString(groupname, patterns) : 810 810 group = StorageGroup(self, groupname) 811 811 group.ident = groupid 812 group.Name = fields.get("pykotaGroupName", [self.databaseToU serCharset(groupname)])[0]812 group.Name = fields.get("pykotaGroupName", [self.databaseToUnicode(groupname)])[0] 813 813 group.LimitBy = fields.get("pykotaLimitBy", ["quota"])[0] 814 group.Description = self.databaseToU serCharset(fields.get("description", [""])[0])814 group.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 815 815 group.AccountBalance = 0.0 816 816 group.LifeTimePaid = 0.0 … … 827 827 """Returns the list of users who uses a given printer, along with their quotas.""" 828 828 usersandquotas = [] 829 pname = self.u serCharsetToDatabase(printer.Name)830 names = [self.u serCharsetToDatabase(n) for n in names]829 pname = self.unicodeToDatabase(printer.Name) 830 names = [self.unicodeToDatabase(n) for n in names] 831 831 if self.info["userquotabase"].lower() == "user" : 832 832 base = self.info["userbase"] … … 839 839 if result : 840 840 for (userquotaid, fields) in result : 841 user = self.getUser(self.databaseToU serCharset(fields.get("pykotaUserName")[0]))841 user = self.getUser(self.databaseToUnicode(fields.get("pykotaUserName")[0])) 842 842 userpquota = StorageUserPQuota(self, user, printer) 843 843 userpquota.ident = userquotaid … … 872 872 """Returns the list of groups which uses a given printer, along with their quotas.""" 873 873 groupsandquotas = [] 874 pname = self.u serCharsetToDatabase(printer.Name)875 names = [self.u serCharsetToDatabase(n) for n in names]874 pname = self.unicodeToDatabase(printer.Name) 875 names = [self.unicodeToDatabase(n) for n in names] 876 876 if self.info["groupquotabase"].lower() == "group" : 877 877 base = self.info["groupbase"] … … 884 884 if result : 885 885 for (groupquotaid, fields) in result : 886 group = self.getGroup(self.databaseToU serCharset(fields.get("pykotaGroupName")[0]))886 group = self.getGroup(self.databaseToUnicode(fields.get("pykotaGroupName")[0])) 887 887 grouppquota = self.getGroupPQuota(group, printer) 888 888 groupsandquotas.append((group, grouppquota)) … … 895 895 if oldentry.Exists : 896 896 return oldentry # we return the existing entry 897 printername = self.u serCharsetToDatabase(printer.Name)897 printername = self.unicodeToDatabase(printer.Name) 898 898 fields = { self.info["printerrdn"] : printername, 899 899 "objectClass" : ["pykotaObject", "pykotaPrinter"], … … 902 902 "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 903 903 "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 904 "description" : self.u serCharsetToDatabase(printer.Description or ""),904 "description" : self.unicodeToDatabase(printer.Description or ""), 905 905 "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 906 906 "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), … … 916 916 if oldentry.Exists : 917 917 return oldentry # we return the existing entry 918 uname = self.u serCharsetToDatabase(user.Name)918 uname = self.unicodeToDatabase(user.Name) 919 919 newfields = { 920 920 "pykotaUserName" : uname, 921 921 "pykotaLimitBy" : (user.LimitBy or "quota"), 922 "description" : self.u serCharsetToDatabase(user.Description or ""),922 "description" : self.unicodeToDatabase(user.Description or ""), 923 923 self.info["usermail"] : user.Email or "", 924 924 } … … 991 991 if oldentry.Exists : 992 992 return oldentry # we return the existing entry 993 gname = self.u serCharsetToDatabase(group.Name)993 gname = self.unicodeToDatabase(group.Name) 994 994 newfields = { 995 995 "pykotaGroupName" : gname, 996 996 "pykotaLimitBy" : (group.LimitBy or "quota"), 997 "description" : self.u serCharsetToDatabase(group.Description or "")997 "description" : self.unicodeToDatabase(group.Description or "") 998 998 } 999 999 mustadd = 1 … … 1040 1040 if not fields.has_key(self.info["groupmembers"]) : 1041 1041 fields[self.info["groupmembers"]] = [] 1042 fields[self.info["groupmembers"]].append(self.u serCharsetToDatabase(user.Name))1042 fields[self.info["groupmembers"]].append(self.unicodeToDatabase(user.Name)) 1043 1043 self.doModify(group.ident, fields) 1044 1044 group.Members.append(user) … … 1053 1053 fields[self.info["groupmembers"]] = [] 1054 1054 try : 1055 fields[self.info["groupmembers"]].remove(self.u serCharsetToDatabase(user.Name))1055 fields[self.info["groupmembers"]].remove(self.unicodeToDatabase(user.Name)) 1056 1056 except ValueError : 1057 1057 pass # TODO : Strange, shouldn't it be there ? … … 1067 1067 return oldentry # we return the existing entry 1068 1068 uuid = self.genUUID() 1069 uname = self.u serCharsetToDatabase(upq.User.Name)1070 pname = self.u serCharsetToDatabase(upq.Printer.Name)1069 uname = self.unicodeToDatabase(upq.User.Name) 1070 pname = self.unicodeToDatabase(upq.Printer.Name) 1071 1071 fields = { "cn" : uuid, 1072 1072 "objectClass" : ["pykotaObject", "pykotaUserPQuota"], … … 1095 1095 return oldentry # we return the existing entry 1096 1096 uuid = self.genUUID() 1097 gname = self.u serCharsetToDatabase(gpq.Group.Name)1098 pname = self.u serCharsetToDatabase(gpq.Printer.Name)1097 gname = self.unicodeToDatabase(gpq.Group.Name) 1098 pname = self.unicodeToDatabase(gpq.Printer.Name) 1099 1099 fields = { "cn" : uuid, 1100 1100 "objectClass" : ["pykotaObject", "pykotaGroupPQuota"], … … 1116 1116 "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 1117 1117 "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 1118 "description" : self.u serCharsetToDatabase(printer.Description or ""),1118 "description" : self.unicodeToDatabase(printer.Description or ""), 1119 1119 "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 1120 1120 "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), … … 1126 1126 newfields = { 1127 1127 "pykotaLimitBy" : (user.LimitBy or "quota"), 1128 "description" : self.u serCharsetToDatabase(user.Description or ""),1128 "description" : self.unicodeToDatabase(user.Description or ""), 1129 1129 self.info["usermail"] : user.Email or "", 1130 1130 } … … 1141 1141 newfields = { 1142 1142 "pykotaLimitBy" : (group.LimitBy or "quota"), 1143 "description" : self.u serCharsetToDatabase(group.Description or ""),1143 "description" : self.unicodeToDatabase(group.Description or ""), 1144 1144 } 1145 1145 self.doModify(group.ident, newfields) … … 1178 1178 payments = [] 1179 1179 for payment in user.Payments : 1180 payments.append("%s # %s # %s" % (payment[0], str(payment[1]), base64.encodestring(self.u serCharsetToDatabase(payment[2])).strip()))1181 payments.append("%s # %s # %s" % (str(DateTime.now()), str(amount), base64.encodestring(self.u serCharsetToDatabase(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())) 1182 1182 fields = { 1183 1183 "pykotaPayments" : payments, … … 1195 1195 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) : 1196 1196 """Adds a job in a printer's history.""" 1197 uname = self.u serCharsetToDatabase(user.Name)1198 pname = self.u serCharsetToDatabase(printer.Name)1197 uname = self.unicodeToDatabase(user.Name) 1198 pname = self.unicodeToDatabase(printer.Name) 1199 1199 if (not self.disablehistory) or (not printer.LastJob.Exists) : 1200 1200 uuid = self.genUUID() … … 1214 1214 "pykotaPrinterPageCounter" : str(pagecounter), 1215 1215 "pykotaAction" : action, 1216 "pykotaFileName" : ((filename is None) and "None") or self.u serCharsetToDatabase(filename),1217 "pykotaTitle" : ((title is None) and "None") or self.u serCharsetToDatabase(title),1216 "pykotaFileName" : ((filename is None) and "None") or self.unicodeToDatabase(filename), 1217 "pykotaTitle" : ((title is None) and "None") or self.unicodeToDatabase(title), 1218 1218 "pykotaCopies" : str(copies), 1219 "pykotaOptions" : ((options is None) and "None") or self.u serCharsetToDatabase(options),1219 "pykotaOptions" : ((options is None) and "None") or self.unicodeToDatabase(options), 1220 1220 "pykotaHostName" : str(clienthost), 1221 1221 "pykotaJobSizeBytes" : str(jobsizebytes), 1222 1222 "pykotaMD5Sum" : str(jobmd5sum), 1223 1223 "pykotaPages" : jobpages, # don't add this attribute if it is not set, so no string conversion 1224 "pykotaBillingCode" : self.u serCharsetToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion1224 "pykotaBillingCode" : self.unicodeToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion 1225 1225 "pykotaPrecomputedJobSize" : str(precomputedsize), 1226 1226 "pykotaPrecomputedJobPrice" : str(precomputedprice), … … 1314 1314 where = [] 1315 1315 if user is not None : 1316 where.append("(pykotaUserName=%s)" % self.u serCharsetToDatabase(user.Name))1316 where.append("(pykotaUserName=%s)" % self.unicodeToDatabase(user.Name)) 1317 1317 if printer is not None : 1318 where.append("(pykotaPrinterName=%s)" % self.u serCharsetToDatabase(printer.Name))1318 where.append("(pykotaPrinterName=%s)" % self.unicodeToDatabase(printer.Name)) 1319 1319 if hostname is not None : 1320 1320 where.append("(pykotaHostName=%s)" % hostname) 1321 1321 if billingcode is not None : 1322 where.append("(pykotaBillingCode=%s)" % self.u serCharsetToDatabase(billingcode))1322 where.append("(pykotaBillingCode=%s)" % self.unicodeToDatabase(billingcode)) 1323 1323 if jobid is not None : 1324 where.append("(pykotaJobId=%s)" % jobid) # TODO : jobid is text, so self.u serCharsetToDatabase(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. 1325 1325 if where : 1326 1326 where = "(&%s)" % "".join([precond] + where) … … 1363 1363 job.JobPrice = None 1364 1364 job.JobAction = fields.get("pykotaAction", [""])[0] 1365 job.JobFileName = self.databaseToU serCharset(fields.get("pykotaFileName", [""])[0])1366 job.JobTitle = self.databaseToU serCharset(fields.get("pykotaTitle", [""])[0])1365 job.JobFileName = self.databaseToUnicode(fields.get("pykotaFileName", [""])[0]) 1366 job.JobTitle = self.databaseToUnicode(fields.get("pykotaTitle", [""])[0]) 1367 1367 job.JobCopies = int(fields.get("pykotaCopies", [0])[0]) 1368 job.JobOptions = self.databaseToU serCharset(fields.get("pykotaOptions", [""])[0])1368 job.JobOptions = self.databaseToUnicode(fields.get("pykotaOptions", [""])[0]) 1369 1369 job.JobHostName = fields.get("pykotaHostName", [""])[0] 1370 1370 job.JobSizeBytes = fields.get("pykotaJobSizeBytes", [0L])[0] 1371 job.JobBillingCode = self.databaseToU serCharset(fields.get("pykotaBillingCode", [None])[0])1371 job.JobBillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [None])[0]) 1372 1372 job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 1373 1373 job.JobPages = fields.get("pykotaPages", [""])[0] … … 1389 1389 ((end is None) and (job.JobDate >= start)) or \ 1390 1390 ((job.JobDate >= start) and (job.JobDate <= end)) : 1391 job.UserName = self.databaseToU serCharset(fields.get("pykotaUserName")[0])1392 job.PrinterName = self.databaseToU serCharset(fields.get("pykotaPrinterName")[0])1391 job.UserName = self.databaseToUnicode(fields.get("pykotaUserName")[0]) 1392 job.PrinterName = self.databaseToUnicode(fields.get("pykotaPrinterName")[0]) 1393 1393 job.Exists = True 1394 1394 jobs.append(job) … … 1400 1400 def deleteUser(self, user) : 1401 1401 """Completely deletes an user from the Quota Storage.""" 1402 uname = self.u serCharsetToDatabase(user.Name)1402 uname = self.unicodeToDatabase(user.Name) 1403 1403 todelete = [] 1404 1404 result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s))" % uname, base=self.info["jobbase"]) … … 1418 1418 # if last job of current printer was printed by the user 1419 1419 # to delete, we also need to delete the printer's last job entry. 1420 printer = self.getPrinter(self.databaseToU serCharset(fields["pykotaPrinterName"][0]))1420 printer = self.getPrinter(self.databaseToUnicode(fields["pykotaPrinterName"][0])) 1421 1421 if printer.LastJob.UserName == user.Name : 1422 1422 todelete.append(printer.LastJob.lastjobident) … … 1453 1453 def deleteGroup(self, group) : 1454 1454 """Completely deletes a group from the Quota Storage.""" 1455 gname = self.u serCharsetToDatabase(group.Name)1455 gname = self.unicodeToDatabase(group.Name) 1456 1456 if self.info["groupquotabase"].lower() == "group" : 1457 1457 base = self.info["groupbase"] … … 1524 1524 def deleteUserPQuota(self, upquota) : 1525 1525 """Completely deletes an user print quota entry from the database.""" 1526 uname = self.u serCharsetToDatabase(upquota.User.Name)1527 pname = self.u serCharsetToDatabase(upquota.Printer.Name)1526 uname = self.unicodeToDatabase(upquota.User.Name) 1527 pname = self.unicodeToDatabase(upquota.Printer.Name) 1528 1528 result = self.doSearch("(&(objectClass=pykotaJob)(pykotaUserName=%s)(pykotaPrinterName=%s))" \ 1529 1529 % (uname, pname), \ … … 1541 1541 def deletePrinter(self, printer) : 1542 1542 """Completely deletes a printer from the Quota Storage.""" 1543 pname = self.u serCharsetToDatabase(printer.Name)1543 pname = self.unicodeToDatabase(printer.Name) 1544 1544 result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % pname, base=self.info["lastjobbase"]) 1545 1545 for (ident, fields) in result : … … 1764 1764 """Extracts billing code information given its label : returns first matching billing code.""" 1765 1765 code = StorageBillingCode(self, label) 1766 ulabel = self.u serCharsetToDatabase(label)1766 ulabel = self.unicodeToDatabase(label) 1767 1767 result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % \ 1768 1768 ulabel, \ … … 1772 1772 fields = result[0][1] # take only first matching code, ignore the rest 1773 1773 code.ident = result[0][0] 1774 code.BillingCode = self.databaseToU serCharset(fields.get("pykotaBillingCode", [ulabel])[0])1774 code.BillingCode = self.databaseToUnicode(fields.get("pykotaBillingCode", [ulabel])[0]) 1775 1775 code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 1776 1776 code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) 1777 code.Description = self.databaseToU serCharset(fields.get("description", [""])[0])1777 code.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 1778 1778 code.Exists = True 1779 1779 return code … … 1788 1788 fields = { "objectClass" : ["pykotaObject", "pykotaBilling"], 1789 1789 "cn" : uuid, 1790 "pykotaBillingCode" : self.u serCharsetToDatabase(bcode.BillingCode),1790 "pykotaBillingCode" : self.unicodeToDatabase(bcode.BillingCode), 1791 1791 "pykotaPageCounter" : str(bcode.PageCounter or 0), 1792 1792 "pykotaBalance" : str(bcode.Balance or 0.0), 1793 "description" : self.u serCharsetToDatabase(bcode.Description or ""),1793 "description" : self.unicodeToDatabase(bcode.Description or ""), 1794 1794 } 1795 1795 self.doAdd(dn, fields) … … 1800 1800 """Sets the new description for a billing code.""" 1801 1801 fields = { 1802 "description" : self.u serCharsetToDatabase(bcode.Description or ""),1802 "description" : self.unicodeToDatabase(bcode.Description or ""), 1803 1803 "pykotaPageCounter" : str(bcode.PageCounter or 0), 1804 1804 "pykotaBalance" : str(bcode.Balance or 0.0), … … 1822 1822 patdict[p] = None 1823 1823 for (codeid, fields) in result : 1824 codename = self.databaseToU serCharset(fields.get("pykotaBillingCode", [""])[0])1824 codename = self.databaseToUnicode(fields.get("pykotaBillingCode", [""])[0]) 1825 1825 if patdict.has_key(codename) or self.tool.matchString(codename, patterns) : 1826 1826 code = StorageBillingCode(self, codename) … … 1828 1828 code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 1829 1829 code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) 1830 code.Description = self.databaseToU serCharset(fields.get("description", [""])[0])1830 code.Description = self.databaseToUnicode(fields.get("description", [""])[0]) 1831 1831 code.Exists = True 1832 1832 codes.append(code) -
pykota/trunk/pykota/storages/pgstorage.py
r3288 r3291 154 154 field = fields[j] 155 155 if type(field) == StringType : 156 fields[j] = self.databaseToU serCharset(field)156 fields[j] = self.databaseToUnicode(field) 157 157 entries[i] = tuple(fields) 158 158 return entries -
pykota/trunk/pykota/storages/sql.py
r3275 r3291 36 36 user.LifeTimePaid = record.get("lifetimepaid") 37 37 user.Email = record.get("email") 38 user.Description = self.databaseToU serCharset(record.get("description"))38 user.Description = self.databaseToUnicode(record.get("description")) 39 39 user.OverCharge = record.get("overcharge", 1.0) 40 40 user.Exists = True … … 48 48 group.AccountBalance = record.get("balance") 49 49 group.LifeTimePaid = record.get("lifetimepaid") 50 group.Description = self.databaseToU serCharset(record.get("description"))50 group.Description = self.databaseToUnicode(record.get("description")) 51 51 group.Exists = True 52 52 return group … … 64 64 else : 65 65 printer.PassThrough = False 66 printer.Description = self.databaseToU serCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?66 printer.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ? 67 67 printer.Exists = True 68 68 return printer … … 76 76 job.JobPrice = record.get("jobprice") 77 77 job.JobAction = record.get("action") 78 job.JobFileName = self.databaseToU serCharset(record.get("filename") or "")79 job.JobTitle = self.databaseToU serCharset(record.get("title") or "")78 job.JobFileName = self.databaseToUnicode(record.get("filename") or "") 79 job.JobTitle = self.databaseToUnicode(record.get("title") or "") 80 80 job.JobCopies = record.get("copies") 81 job.JobOptions = self.databaseToU serCharset(record.get("options") or "")81 job.JobOptions = self.databaseToUnicode(record.get("options") or "") 82 82 job.JobDate = record.get("jobdate") 83 83 job.JobHostName = record.get("hostname") … … 85 85 job.JobMD5Sum = record.get("md5sum") 86 86 job.JobPages = record.get("pages") 87 job.JobBillingCode = self.databaseToU serCharset(record.get("billingcode") or "")87 job.JobBillingCode = self.databaseToUnicode(record.get("billingcode") or "") 88 88 job.PrecomputedJobSize = record.get("precomputedjobsize") 89 89 job.PrecomputedJobPrice = record.get("precomputedjobprice") 90 job.UserName = self.databaseToU serCharset(record.get("username"))91 job.PrinterName = self.databaseToU serCharset(record.get("printername"))90 job.UserName = self.databaseToUnicode(record.get("username")) 91 job.PrinterName = self.databaseToUnicode(record.get("printername")) 92 92 if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" : 93 93 (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 … … 138 138 code = StorageBillingCode(self, billingcode) 139 139 code.ident = record.get("id") 140 code.Description = self.databaseToU serCharset(record.get("description") or "") # TODO : is 'or ""' still needed ?140 code.Description = self.databaseToUnicode(record.get("description") or "") # TODO : is 'or ""' still needed ? 141 141 code.Balance = record.get("balance") or 0.0 142 142 code.PageCounter = record.get("pagecounter") or 0 … … 149 149 expressions = [] 150 150 for (k, v) in only.items() : 151 expressions.append("%s=%s" % (k, self.doQuote(self.u serCharsetToDatabase(v))))151 expressions.append("%s=%s" % (k, self.doQuote(self.unicodeToDatabase(v)))) 152 152 return " AND ".join(expressions) 153 153 return "" … … 299 299 self.tool.printInfo("Object %s has no %s attribute !" % (repr(record), attribute), "error") 300 300 else : 301 attrval = self.databaseToU serCharset(attrval)301 attrval = self.databaseToUnicode(attrval) 302 302 if patterns : 303 303 if (not isinstance(patterns, type([]))) and (not isinstance(patterns, type(()))) : … … 351 351 """Extracts user information given its name.""" 352 352 result = self.doSearch("SELECT * FROM users WHERE username=%s"\ 353 % self.doQuote(self.u serCharsetToDatabase(username)))353 % self.doQuote(self.unicodeToDatabase(username))) 354 354 if result : 355 355 return self.storageUserFromRecord(username, result[0]) … … 360 360 """Extracts group information given its name.""" 361 361 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.u serCharsetToDatabase(groupname)))362 % self.doQuote(self.unicodeToDatabase(groupname))) 363 363 if result : 364 364 return self.storageGroupFromRecord(groupname, result[0]) … … 369 369 """Extracts printer information given its name.""" 370 370 result = self.doSearch("SELECT * FROM printers WHERE printername=%s" \ 371 % self.doQuote(self.u serCharsetToDatabase(printername)))371 % self.doQuote(self.unicodeToDatabase(printername))) 372 372 if result : 373 373 return self.storagePrinterFromRecord(printername, result[0]) … … 378 378 """Extracts a billing code information given its name.""" 379 379 result = self.doSearch("SELECT * FROM billingcodes WHERE billingcode=%s" \ 380 % self.doQuote(self.u serCharsetToDatabase(label)))380 % self.doQuote(self.unicodeToDatabase(label))) 381 381 if result : 382 382 return self.storageBillingCodeFromRecord(label, result[0]) … … 416 416 if result : 417 417 for record in result : 418 user = self.storageUserFromRecord(self.databaseToU serCharset(record.get("username")), \418 user = self.storageUserFromRecord(self.databaseToUnicode(record.get("username")), \ 419 419 record) 420 420 groupmembers.append(user) … … 428 428 if result : 429 429 for record in result : 430 groups.append(self.getGroup(self.databaseToU serCharset(record.get("groupname"))))430 groups.append(self.getGroup(self.databaseToUnicode(record.get("groupname")))) 431 431 return groups 432 432 … … 438 438 for record in result : 439 439 if record["groupid"] != printer.ident : # in case of integrity violation 440 parentprinter = self.getPrinter(self.databaseToU serCharset(record.get("printername")))440 parentprinter = self.getPrinter(self.databaseToUnicode(record.get("printername"))) 441 441 if parentprinter.Exists : 442 442 pgroups.append(parentprinter) … … 460 460 patdict[p] = None 461 461 for record in result : 462 pname = self.databaseToU serCharset(record["printername"])462 pname = self.databaseToUnicode(record["printername"]) 463 463 if patdict.has_key(pname) or self.tool.matchString(pname, patterns) : 464 464 printer = self.storagePrinterFromRecord(pname, record) … … 484 484 patdict[p] = None 485 485 for record in result : 486 uname = self.databaseToU serCharset(record["username"])486 uname = self.databaseToUnicode(record["username"]) 487 487 if patdict.has_key(uname) or self.tool.matchString(uname, patterns) : 488 488 user = self.storageUserFromRecord(uname, record) … … 508 508 patdict[p] = None 509 509 for record in result : 510 gname = self.databaseToU serCharset(record["groupname"])510 gname = self.databaseToUnicode(record["groupname"]) 511 511 if patdict.has_key(gname) or self.tool.matchString(gname, patterns) : 512 512 group = self.storageGroupFromRecord(gname, record) … … 529 529 patdict[p] = None 530 530 for record in result : 531 codename = self.databaseToU serCharset(record["billingcode"])531 codename = self.databaseToUnicode(record["billingcode"]) 532 532 if patdict.has_key(codename) or self.tool.matchString(codename, patterns) : 533 533 code = self.storageBillingCodeFromRecord(codename, record) … … 542 542 if result : 543 543 for record in result : 544 uname = self.databaseToU serCharset(record.get("username"))544 uname = self.databaseToUnicode(record.get("username")) 545 545 if self.tool.matchString(uname, names) : 546 546 user = self.storageUserFromRecord(uname, record) … … 557 557 if result : 558 558 for record in result : 559 gname = self.databaseToU serCharset(record.get("groupname"))559 gname = self.databaseToUnicode(record.get("groupname")) 560 560 if self.tool.matchString(gname, names) : 561 561 group = self.getGroup(gname) … … 570 570 return oldentry 571 571 self.doModify("INSERT INTO printers (printername, passthrough, maxjobsize, description, priceperpage, priceperjob) VALUES (%s, %s, %s, %s, %s, %s)" \ 572 % (self.doQuote(self.u serCharsetToDatabase(printer.Name)), \572 % (self.doQuote(self.unicodeToDatabase(printer.Name)), \ 573 573 self.doQuote((printer.PassThrough and "t") or "f"), \ 574 574 self.doQuote(printer.MaxJobSize or 0), \ 575 self.doQuote(self.u serCharsetToDatabase(printer.Description)), \575 self.doQuote(self.unicodeToDatabase(printer.Description)), \ 576 576 self.doQuote(printer.PricePerPage or 0.0), \ 577 577 self.doQuote(printer.PricePerJob or 0.0))) … … 585 585 return oldentry 586 586 self.doModify("INSERT INTO billingcodes (billingcode, balance, pagecounter, description) VALUES (%s, %s, %s, %s)" \ 587 % (self.doQuote(self.u serCharsetToDatabase(bcode.BillingCode)),587 % (self.doQuote(self.unicodeToDatabase(bcode.BillingCode)), 588 588 self.doQuote(bcode.Balance or 0.0), \ 589 589 self.doQuote(bcode.PageCounter or 0), \ 590 self.doQuote(self.u serCharsetToDatabase(bcode.Description))))590 self.doQuote(self.unicodeToDatabase(bcode.Description)))) 591 591 bcode.isDirty = False 592 592 return None # the entry created doesn't need further modification … … 598 598 return oldentry 599 599 self.doModify("INSERT INTO users (username, limitby, balance, lifetimepaid, email, overcharge, description) VALUES (%s, %s, %s, %s, %s, %s, %s)" % \ 600 (self.doQuote(self.u serCharsetToDatabase(user.Name)), \600 (self.doQuote(self.unicodeToDatabase(user.Name)), \ 601 601 self.doQuote(user.LimitBy or 'quota'), \ 602 602 self.doQuote(user.AccountBalance or 0.0), \ … … 604 604 self.doQuote(user.Email), \ 605 605 self.doQuote(user.OverCharge), \ 606 self.doQuote(self.u serCharsetToDatabase(user.Description))))606 self.doQuote(self.unicodeToDatabase(user.Description)))) 607 607 if user.PaymentsBacklog : 608 608 for (value, comment) in user.PaymentsBacklog : … … 618 618 return oldentry 619 619 self.doModify("INSERT INTO groups (groupname, limitby, description) VALUES (%s, %s, %s)" % \ 620 (self.doQuote(self.u serCharsetToDatabase(group.Name)), \620 (self.doQuote(self.unicodeToDatabase(group.Name)), \ 621 621 self.doQuote(group.LimitBy or "quota"), \ 622 self.doQuote(self.u serCharsetToDatabase(group.Description))))622 self.doQuote(self.unicodeToDatabase(group.Description)))) 623 623 group.isDirty = False 624 624 return None # the entry created doesn't need further modification … … 677 677 % (self.doQuote((printer.PassThrough and "t") or "f"), \ 678 678 self.doQuote(printer.MaxJobSize or 0), \ 679 self.doQuote(self.u serCharsetToDatabase(printer.Description)), \679 self.doQuote(self.unicodeToDatabase(printer.Description)), \ 680 680 self.doQuote(printer.PricePerPage or 0.0), \ 681 681 self.doQuote(printer.PricePerJob or 0.0), \ … … 690 690 self.doQuote(user.Email), \ 691 691 self.doQuote(user.OverCharge), \ 692 self.doQuote(self.u serCharsetToDatabase(user.Description)), \692 self.doQuote(self.unicodeToDatabase(user.Description)), \ 693 693 self.doQuote(user.ident))) 694 694 … … 697 697 self.doModify("UPDATE groups SET limitby=%s, description=%s WHERE id=%s" \ 698 698 % (self.doQuote(group.LimitBy or 'quota'), \ 699 self.doQuote(self.u serCharsetToDatabase(group.Description)), \699 self.doQuote(self.unicodeToDatabase(group.Description)), \ 700 700 self.doQuote(group.ident))) 701 701 … … 717 717 % (self.doQuote(bcode.Balance or 0.0), \ 718 718 self.doQuote(bcode.PageCounter or 0), \ 719 self.doQuote(self.u serCharsetToDatabase(bcode.Description)), \719 self.doQuote(self.unicodeToDatabase(bcode.Description)), \ 720 720 self.doQuote(bcode.ident))) 721 721 … … 735 735 """Adds a new payment to the payments history.""" 736 736 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.u serCharsetToDatabase(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)))) 738 738 else : 739 self.doModify("INSERT INTO payments (userid, amount, description) VALUES ((SELECT id FROM users WHERE username=%s), %s, %s)" % (self.doQuote(self.u serCharsetToDatabase(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)))) 740 740 741 741 def writeLastJobSize(self, lastjob, jobsize, jobprice) : … … 748 748 # For legal reasons, we want to hide the title, filename and options 749 749 title = filename = options = "hidden" 750 filename = self.u serCharsetToDatabase(filename)751 title = self.u serCharsetToDatabase(title)752 options = self.u serCharsetToDatabase(options)753 jobbilling = self.u serCharsetToDatabase(jobbilling)750 filename = self.unicodeToDatabase(filename) 751 title = self.unicodeToDatabase(title) 752 options = self.unicodeToDatabase(options) 753 jobbilling = self.unicodeToDatabase(jobbilling) 754 754 if (not self.disablehistory) or (not printer.LastJob.Exists) : 755 755 if jobsize is not None : … … 814 814 where.append("hostname=%s" % self.doQuote(hostname)) 815 815 if billingcode is not None : 816 where.append("billingcode=%s" % self.doQuote(self.u serCharsetToDatabase(billingcode)))816 where.append("billingcode=%s" % self.doQuote(self.unicodeToDatabase(billingcode))) 817 817 if jobid is not None : 818 where.append("jobid=%s" % self.doQuote(jobid)) # TODO : jobid is text, so self.u serCharsetToDatabase(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. 819 819 if start is not None : 820 820 where.append("jobdate>=%s" % self.doQuote(start))