Changeset 3549 for pykota/trunk/pykota/storages
- Timestamp:
- 08/18/10 04:20:57 (14 years ago)
- Location:
- pykota/trunk/pykota/storages
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r3532 r3549 447 447 printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 448 448 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) 449 printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 449 printer.MaxJobSize = fields.get("pykotaMaxJobSize") 450 if printer.MaxJobSize is not None : 451 if printer.MaxJobSize[0].upper() == "NONE" : 452 printer.MaxJobSize = None 453 else : 454 printer.MaxJobSize = int(printer.MaxJobSize[0]) 450 455 printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 451 456 if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : … … 513 518 result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \ 514 519 (unicodeToDatabase(group.Name), unicodeToDatabase(printer.Name)), \ 515 ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit" , "pykotaMaxJobSize"], \520 ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit"], \ 516 521 base=base) 517 522 if result : … … 536 541 else : 537 542 grouppquota.DateLimit = grouppquota.DateLimit[0] 538 grouppquota.MaxJobSize = fields.get("pykotaMaxJobSize")539 if grouppquota.MaxJobSize is not None :540 if grouppquota.MaxJobSize[0].upper() == "NONE" :541 grouppquota.MaxJobSize = None542 else :543 grouppquota.MaxJobSize = int(grouppquota.MaxJobSize[0])544 543 grouppquota.PageCounter = 0 545 544 grouppquota.LifePageCounter = 0 … … 712 711 printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0] or 0.0) 713 712 printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 714 printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 713 printer.MaxJobSize = fields.get("pykotaMaxJobSize") 714 if printer.MaxJobSize is not None : 715 if printer.MaxJobSize[0].upper() == "NONE" : 716 printer.MaxJobSize = None 717 else : 718 printer.MaxJobSize = int(printer.MaxJobSize[0]) 715 719 printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 716 720 if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : … … 892 896 "pykotaPrinterName" : printername, 893 897 "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 894 "pykotaMaxJobSize" : str(printer.MaxJobSize or 0),898 "pykotaMaxJobSize" : str(printer.MaxJobSize), 895 899 "description" : unicodeToDatabase(printer.Description or ""), 896 900 "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), … … 1070 1074 "pykotaLifePageCounter" : str(upq.LifePageCounter or 0), 1071 1075 "pykotaWarnCount" : str(upq.WarnCount or 0), 1072 "pykotaMaxJobSize" : str(upq.MaxJobSize or 0),1076 "pykotaMaxJobSize" : str(upq.MaxJobSize), 1073 1077 } 1074 1078 if self.info["userquotabase"].lower() == "user" : … … 1106 1110 fields = { 1107 1111 "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 1108 "pykotaMaxJobSize" : str(printer.MaxJobSize or 0),1112 "pykotaMaxJobSize" : str(printer.MaxJobSize), 1109 1113 "description" : unicodeToDatabase(printer.Description or ""), 1110 1114 "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), … … 1251 1255 "pykotaPageCounter" : str(userpquota.PageCounter or 0), 1252 1256 "pykotaLifePageCounter" : str(userpquota.LifePageCounter or 0), 1253 "pykotaMaxJobSize" : str(userpquota.MaxJobSize or 0),1257 "pykotaMaxJobSize" : str(userpquota.MaxJobSize), 1254 1258 } 1255 1259 self.doModify(userpquota.ident, fields) … … 1275 1279 "pykotaHardLimit" : str(grouppquota.HardLimit), 1276 1280 "pykotaDateLimit" : str(grouppquota.DateLimit), 1277 "pykotaMaxJobSize" : str(grouppquota.MaxJobSize or 0),1278 1281 } 1279 1282 self.doModify(grouppquota.ident, fields) … … 1680 1683 entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 1681 1684 if entries : 1682 fields = ("username", "printername", "dn", "userdn", "printerdn", "lifepagecounter", "pagecounter", "softlimit", "hardlimit", "datelimit" )1685 fields = ("username", "printername", "dn", "userdn", "printerdn", "lifepagecounter", "pagecounter", "softlimit", "hardlimit", "datelimit", "maxjobsize") 1683 1686 result = [] 1684 1687 uname = extractonly.get("username") 1685 1688 for entry in entries : 1686 1689 for (user, userpquota) in self.getPrinterUsersAndQuotas(entry, names=[uname or "*"]) : 1687 result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit ))1690 result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit, userpquota.MaxJobSize)) 1688 1691 return [fields] + self.sortRecords(fields, result, ["+userdn"], ordering) 1689 1692 -
pykota/trunk/pykota/storages/sql.py
r3541 r3549 62 62 printer.PricePerJob = record.get("priceperjob") or 0.0 63 63 printer.PricePerPage = record.get("priceperpage") or 0.0 64 printer.MaxJobSize = record.get("maxjobsize") or 064 printer.MaxJobSize = record.get("maxjobsize") 65 65 printer.PassThrough = record.get("passthrough") or 0 66 66 if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : … … 119 119 userpquota.HardLimit = record.get("hardlimit") 120 120 userpquota.DateLimit = record.get("datelimit") 121 userpquota.MaxJobSize = record.get("maxjobsize") 121 122 userpquota.WarnCount = record.get("warncount") or 0 122 123 userpquota.Exists = True … … 243 244 thefilter = "AND %s" % thefilter 244 245 orderby = self.createOrderBy(["+grouppquota.id"], ordering) 245 result = self.doRawSearch("SELECT groups.groupname,printers.printername,grouppquota.*,coalesce(sum(pagecounter), 0) AS pagecounter,coalesce(sum(lifepagecounter), 0) AS lifepagecounter FROM groups,printers,grouppquota,userpquota WHERE groups.id=grouppquota.groupid AND printers.id=grouppquota.printerid AND userpquota.printerid=grouppquota.printerid AND userpquota.userid IN (SELECT userid FROM groupsmembers WHERE groupsmembers.groupid=grouppquota.groupid) %(thefilter)s GROUP BY grouppquota.id,grouppquota.groupid,grouppquota.printerid,grouppquota.softlimit,grouppquota.hardlimit,grouppquota.datelimit,group pquota.maxjobsize,groups.groupname,printers.printername ORDER BY %(orderby)s" % locals())246 result = self.doRawSearch("SELECT groups.groupname,printers.printername,grouppquota.*,coalesce(sum(pagecounter), 0) AS pagecounter,coalesce(sum(lifepagecounter), 0) AS lifepagecounter FROM groups,printers,grouppquota,userpquota WHERE groups.id=grouppquota.groupid AND printers.id=grouppquota.printerid AND userpquota.printerid=grouppquota.printerid AND userpquota.userid IN (SELECT userid FROM groupsmembers WHERE groupsmembers.groupid=grouppquota.groupid) %(thefilter)s GROUP BY grouppquota.id,grouppquota.groupid,grouppquota.printerid,grouppquota.softlimit,grouppquota.hardlimit,grouppquota.datelimit,groups.groupname,printers.printername ORDER BY %(orderby)s" % locals()) 246 247 return self.prepareRawResult(result) 247 248 … … 560 561 % (self.doQuote(unicodeToDatabase(printer.Name)), \ 561 562 self.doQuote((printer.PassThrough and "t") or "f"), \ 562 self.doQuote(printer.MaxJobSize or 0), \563 self.doQuote(printer.MaxJobSize), \ 563 564 self.doQuote(unicodeToDatabase(printer.Description)), \ 564 565 self.doQuote(printer.PricePerPage or 0.0), \ … … 650 651 if oldentry.Exists : 651 652 return oldentry 652 self.doModify("INSERT INTO grouppquota (groupid, printerid, softlimit, hardlimit, datelimit , maxjobsize) VALUES (%s,%s, %s, %s, %s, %s)" \653 self.doModify("INSERT INTO grouppquota (groupid, printerid, softlimit, hardlimit, datelimit) VALUES (%s, %s, %s, %s, %s)" \ 653 654 % (self.doQuote(gpq.Group.ident), \ 654 655 self.doQuote(gpq.Printer.ident), \ 655 656 self.doQuote(gpq.SoftLimit), \ 656 657 self.doQuote(gpq.HardLimit), \ 657 self.doQuote(gpq.DateLimit), \ 658 self.doQuote(gpq.MaxJobSize))) 658 self.doQuote(gpq.DateLimit))) 659 659 gpq.isDirty = False 660 660 return None # the entry created doesn't need further modification … … 664 664 self.doModify("UPDATE printers SET passthrough=%s, maxjobsize=%s, description=%s, priceperpage=%s, priceperjob=%s WHERE id=%s" \ 665 665 % (self.doQuote((printer.PassThrough and "t") or "f"), \ 666 self.doQuote(printer.MaxJobSize or 0), \666 self.doQuote(printer.MaxJobSize), \ 667 667 self.doQuote(unicodeToDatabase(printer.Description)), \ 668 668 self.doQuote(printer.PricePerPage or 0.0), \