Changeset 2749
- Timestamp:
- 02/23/06 11:58:05 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r2743 r2749 32 32 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 33 33 from pykota.config import PyKotaConfigError 34 from pykota.storage import PyKotaStorageError 34 from pykota.storage import PyKotaStorageError, StorageUserPQuota, StorageGroupPQuota 35 35 36 36 __doc__ = N_("""edpykota v%(__version__)s (c) %(__years__)s %(__author__)s … … 163 163 names = ["*"] 164 164 165 before = time.time()166 (printers, entries, pqentries) = getattr(self.storage, "getPrinters%ssAndPQuotas" % suffix)(printernames, names)167 after = time.time()168 self.printInfo("Data extraction took : %.4f seconds" % (after - before))165 if not options["list"] : 166 self.display(_("Extracting datas...")) 167 printers = self.storage.getMatchingPrinters(options["printer"]) 168 entries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 169 169 170 170 if options["delete"] : 171 self.display("%s...\n" % _("Deletion")) 172 nbtotal = len(pqentries) 173 for i in range(nbtotal) : 174 (pqkey, pqentry) = pqentries.popitem() 175 if pqentry.Exists : 176 pqentry.delete() 177 percent = 100.0 * float(i) / float(nbtotal) 178 self.display("\r%.02f%%" % percent) 171 self.display("\n%s..." % _("Deletion")) 172 getattr(self.storage, "deleteMany%sPQuotas" % suffix)(printers, entries) 173 self.display("\n") 174 self.display("\r100.00%%\r \r%s\n" % _("Done.")) 179 175 else : 180 176 skipexisting = options["skipexisting"] 177 used = options["used"] 178 if used : 179 used = used.strip() 180 try : 181 int(used) 182 except ValueError : 183 raise PyKotaCommandLineError, _("Invalid used value %s.") % used 184 185 increase = options["increase"] 186 if increase : 187 try : 188 increase = int(increase.strip()) 189 except ValueError : 190 raise PyKotaCommandLineError, _("Invalid increase value %s.") % increase 191 192 softlimit = hardlimit = None 193 noquota = options["noquota"] 194 if not noquota : 195 if options["softlimit"] : 196 try : 197 softlimit = int(options["softlimit"].strip()) 198 if softlimit < 0 : 199 raise ValueError 200 except ValueError : 201 raise PyKotaCommandLineError, _("Invalid softlimit value %s.") % options["softlimit"] 202 if options["hardlimit"] : 203 try : 204 hardlimit = int(options["hardlimit"].strip()) 205 if hardlimit < 0 : 206 raise ValueError 207 except ValueError : 208 raise PyKotaCommandLineError, _("Invalid hardlimit value %s.") % options["hardlimit"] 209 if (softlimit is not None) and (hardlimit is not None) and (hardlimit < softlimit) : 210 # error, exchange them 211 self.printInfo(_("Hard limit %i is less than soft limit %i, values will be exchanged.") % (hardlimit, softlimit)) 212 (softlimit, hardlimit) = (hardlimit, softlimit) 213 if hardlimit is None : 214 hardlimit = softlimit 215 if hardlimit is not None : 216 self.printInfo(_("Undefined hard limit set to soft limit (%s).") % str(hardlimit)) 217 if softlimit is None : 218 softlimit = hardlimit 219 if softlimit is not None : 220 self.printInfo(_("Undefined soft limit set to hard limit (%s).") % str(softlimit)) 221 222 pqentries = [] 181 223 if options["add"] : 182 self.display("%s...\n" % _("Creation")) 183 mentries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) 224 self.display("\n%s...\n" % _("Creation")) 184 225 dicnames = {} 185 for m in mentries :226 for m in entries : 186 227 dicnames[m.Name] = None 187 228 for name in names : 188 229 if not dicnames.has_key(name) : 189 self.printInfo(_("Impossible to create print quota entries if the user or group object %s doesn't already exist. Please use pkusers to create it first.") % name, "warn") 190 mprinters = self.storage.getMatchingPrinters(options["printer"]) 191 nbtotal = len(mprinters) * len(mentries) 230 self.printInfo(_("Impossible to create print quota entries if the user or group object '%s' doesn't already exist. Please use pkusers to create it first.") % name, "warn") 231 232 factory = globals()["Storage%sPQuota" % suffix] 233 nbtotal = len(printers) * len(entries) 192 234 i = 0 193 for printer in mprinters :235 for printer in printers : 194 236 pname = printer.Name 195 for entry in mentries :237 for entry in entries : 196 238 ename = entry.Name 197 239 pqkey = "%s@%s" % (ename, pname) 198 if pqentries.has_key(pqkey) and pqentries[pqkey].Exists : 199 if skipexisting : 200 self.printInfo(_("%s print quota entry %s@%s already exists, skipping.") % (suffix, ename, pname)) 201 del pqentries[pqkey] 202 else : 203 self.printInfo(_("%s print quota entry %s@%s already exists, will be modified.") % (suffix, ename, pname)) 204 else : 205 newpqentry = getattr(self.storage, "add%sPQuota" % suffix)(entry, printer) 206 if not newpqentry.Exists : 207 self.printInfo(_("Impossible to create a print quota entry for %s@%s") % (ename, pname)) 208 else : 209 pqentries[pqkey] = newpqentry 210 i += 1 211 percent = 100.0 * float(i) / float(nbtotal) 212 self.display("\r%.02f%%" % percent) 213 self.display("\r100.00%%\r \r%s\n" % _("Done.")) 214 215 if not pqentries : 216 raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names)) 217 218 if options["list"] : 219 for (name, entry) in pqentries.items() : 220 if entry.Exists : 221 print name 222 print " %s" % (_("Page counter : %s") % entry.PageCounter) 223 print " %s" % (_("Lifetime page counter : %s") % entry.LifePageCounter) 224 print " %s" % (_("Soft limit : %s") % entry.SoftLimit) 225 print " %s" % (_("Hard limit : %s") % entry.HardLimit) 226 print " %s" % (_("Date limit : %s") % entry.DateLimit) 227 # TODO : print " %s" % (_("Maximum job size : %s") % ((entry.MaxJobSize and (_("%s pages") % entry.MaxJobSize)) or _("Unlimited"))) 228 if hasattr(entry, "WarnCount") : 229 print " %s" % (_("Warning banners printed : %s") % entry.WarnCount) 230 print 231 else : 232 self.display("%s...\n" % _("Modification")) 233 234 used = options["used"] 235 if used : 236 used = used.strip() 237 try : 238 int(used) 239 except ValueError : 240 raise PyKotaCommandLineError, _("Invalid used value %s.") % used 241 242 increase = options["increase"] 243 if increase : 244 try : 245 increase = int(increase.strip()) 246 except ValueError : 247 raise PyKotaCommandLineError, _("Invalid increase value %s.") % increase 248 249 softlimit = hardlimit = None 250 noquota = options["noquota"] 251 if not noquota : 252 if options["softlimit"] : 253 try : 254 softlimit = int(options["softlimit"].strip()) 255 if softlimit < 0 : 256 raise ValueError 257 except ValueError : 258 raise PyKotaCommandLineError, _("Invalid softlimit value %s.") % options["softlimit"] 259 if options["hardlimit"] : 260 try : 261 hardlimit = int(options["hardlimit"].strip()) 262 if hardlimit < 0 : 263 raise ValueError 264 except ValueError : 265 raise PyKotaCommandLineError, _("Invalid hardlimit value %s.") % options["hardlimit"] 266 if (softlimit is not None) and (hardlimit is not None) and (hardlimit < softlimit) : 267 # error, exchange them 268 self.printInfo(_("Hard limit %i is less than soft limit %i, values will be exchanged.") % (hardlimit, softlimit)) 269 (softlimit, hardlimit) = (hardlimit, softlimit) 270 if hardlimit is None : 271 hardlimit = softlimit 272 if hardlimit is not None : 273 self.printInfo(_("Undefined hard limit set to soft limit (%s) on printer %s.") % (str(hardlimit), printer.Name)) 274 if softlimit is None : 275 softlimit = hardlimit 276 if softlimit is not None : 277 self.printInfo(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer.Name)) 278 279 nbtotal = len(pqentries) 280 i = 0 281 for (pqkey, pqentry) in pqentries.items() : 282 ename = getattr(pqentry, suffix).Name 283 pname = pqentry.Printer.Name 284 if pqentry.Exists : 240 pqentry = factory(self.storage, entry, printer) 285 241 if noquota or ((softlimit is not None) and (hardlimit is not None)) : 286 242 pqentry.setLimits(softlimit, hardlimit) 287 243 288 244 if increase : 289 if (pqentry.SoftLimit is None) \ 290 or (pqentry.HardLimit is None) : 291 self.printInfo(_("You can't increase limits by %s when no limit is set.") % increase, "error") 292 else : 293 newsoft = pqentry.SoftLimit + increase 294 newhard = pqentry.HardLimit + increase 295 if (newsoft >= 0) and (newhard >= 0) : 296 pqentry.setLimits(newsoft, newhard) 297 else : 298 self.printInfo(_("You can't set negative limits."), "error") 245 newsoft = (pqentry.SoftLimit or 0) + increase 246 newhard = (pqentry.HardLimit or 0) + increase 247 if (newsoft >= 0) and (newhard >= 0) : 248 pqentry.setLimits(newsoft, newhard) 249 else : 250 self.printInfo(_("You can't set negative limits."), "error") 299 251 300 252 if options["reset"] : … … 307 259 if used : 308 260 pqentry.setUsage(used) 261 262 oldpqentry = getattr(self.storage, "add%sPQuota" % suffix)(pqentry) 263 if oldpqentry is not None : 264 if skipexisting : 265 self.printInfo(_("%s print quota entry %s@%s already exists, skipping.") % (suffix, ename, pname)) 266 else : 267 self.printInfo(_("%s print quota entry %s@%s already exists, will be modified.") % (suffix, ename, pname)) 268 pqentries.append(oldpqentry) 269 i += 1 270 percent = 100.0 * float(i) / float(nbtotal) 271 self.display("\r%.02f%%" % percent) 272 self.display("\r100.00%%\r \r%s" % _("Done.")) 273 else : 274 for printer in printers : 275 for entry in entries : 276 pqentries.append(getattr(self.storage, "get%sPQuota" % suffix)(entry, printer)) 277 if not pqentries : 278 raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names)) 279 280 if options["list"] : 281 for pqentry in pqentries : 282 if pqentry.Exists : 283 print "%s@%s" % (getattr(pqentry, suffix).Name, pqentry.Printer.Name) 284 print " %s" % (_("Page counter : %s") % pqentry.PageCounter) 285 print " %s" % (_("Lifetime page counter : %s") % pqentry.LifePageCounter) 286 print " %s" % (_("Soft limit : %s") % pqentry.SoftLimit) 287 print " %s" % (_("Hard limit : %s") % pqentry.HardLimit) 288 print " %s" % (_("Date limit : %s") % pqentry.DateLimit) 289 print " %s (Not supported yet)" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited"))) 290 if hasattr(pqentry, "WarnCount") : 291 print " %s" % (_("Warning banners printed : %s") % pqentry.WarnCount) 292 print 293 else : 294 self.display("\n") 295 nbtotal = len(pqentries) 296 if nbtotal : 297 self.display("%s...\n" % _("Modification")) 298 i = 0 299 for pqentry in pqentries : 300 ename = getattr(pqentry, suffix).Name 301 pname = pqentry.Printer.Name 302 if pqentry.Exists : 303 if noquota or ((softlimit is not None) and (hardlimit is not None)) : 304 pqentry.setLimits(softlimit, hardlimit) 309 305 310 pqentry.save() 311 i += 1 312 percent = 100.0 * float(i) / float(nbtotal) 313 self.display("\r%.02f%%" % percent) 306 if increase : 307 newsoft = (pqentry.SoftLimit or 0) + increase 308 newhard = (pqentry.HardLimit or 0) + increase 309 if (newsoft >= 0) and (newhard >= 0) : 310 pqentry.setLimits(newsoft, newhard) 311 else : 312 self.printInfo(_("You can't set negative limits for %s@%s") % (ename, pname), "error") 313 314 if options["reset"] : 315 pqentry.reset() 314 316 315 if not options["list"] : 316 self.display("\r100.00%%\r \r%s\n" % _("Done.")) 317 if options["hardreset"] : 318 pqentry.hardreset() 319 320 if not options["groups"] : 321 if used : 322 pqentry.setUsage(used) 323 324 pqentry.save() 325 i += 1 326 percent = 100.0 * float(i) / float(nbtotal) 327 self.display("\r%.02f%%" % percent) 328 self.display("\r100.00%%\r \r%s\n" % _("Done.")) 317 329 318 330 if __name__ == "__main__" : -
pykota/trunk/pykota/storages/ldapstorage.py
r2735 r2749 191 191 self.tool.logdebug("%s" % entry) 192 192 self.database.add_s(dn, entry) 193 except ldap.ALREADY_EXISTS, msg : 194 raise PyKotaStorageError 193 195 except ldap.LDAPError, msg : 194 196 message = (_("Problem adding LDAP entry (%s, %s)") % (dn, str(fields))) + " : %s" % str(msg) … … 454 456 result = self.doSearch("(&(objectClass=pykotaUserPQuota)(pykotaUserName=%s)(pykotaPrinterName=%s))" % \ 455 457 (self.userCharsetToDatabase(user.Name), self.userCharsetToDatabase(printer.Name)), \ 456 ["pykotaPageCounter", "pykotaLifePageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaWarnCount" ], \458 ["pykotaPageCounter", "pykotaLifePageCounter", "pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaWarnCount", "pykotaMaxJobSize"], \ 457 459 base=base) 458 460 if result : … … 480 482 else : 481 483 userpquota.DateLimit = userpquota.DateLimit[0] 484 userpquota.MaxJobSize = fields.get("pykotaMaxJobSize") 485 if userpquota.MaxJobSize is not None : 486 if userpquota.MaxJobSize[0].upper() == "NONE" : 487 userpquota.MaxJobSize = None 488 else : 489 userpquota.MaxJobSize = int(userpquota.MaxJobSize[0]) 482 490 userpquota.Exists = 1 483 491 return userpquota … … 493 501 result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \ 494 502 (self.userCharsetToDatabase(group.Name), self.userCharsetToDatabase(printer.Name)), \ 495 ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit" ], \503 ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaMaxJobSize"], \ 496 504 base=base) 497 505 if result : … … 516 524 else : 517 525 grouppquota.DateLimit = grouppquota.DateLimit[0] 526 grouppquota.MaxJobSize = fields.get("pykotaMaxJobSize") 527 if grouppquota.MaxJobSize is not None : 528 if grouppquota.MaxJobSize[0].upper() == "NONE" : 529 grouppquota.MaxJobSize = None 530 else : 531 grouppquota.MaxJobSize = int(grouppquota.MaxJobSize[0]) 518 532 grouppquota.PageCounter = 0 519 533 grouppquota.LifePageCounter = 0 … … 1018 1032 raise "Not Implemented !" # TODO !!! 1019 1033 1020 def addUserPQuota(self, u ser, printer) :1034 def addUserPQuota(self, upq) : 1021 1035 """Initializes a user print quota on a printer.""" 1036 # first check if an entry already exists 1037 oldentry = self.getUserPQuota(upq.User, upq.Printer) 1038 if oldentry.Exists : 1039 return oldentry # we return the existing entry 1022 1040 uuid = self.genUUID() 1023 uname = self.userCharsetToDatabase(u ser.Name)1024 pname = self.userCharsetToDatabase( printer.Name)1041 uname = self.userCharsetToDatabase(upq.User.Name) 1042 pname = self.userCharsetToDatabase(upq.Printer.Name) 1025 1043 fields = { "cn" : uuid, 1026 1044 "objectClass" : ["pykotaObject", "pykotaUserPQuota"], 1027 1045 "pykotaUserName" : uname, 1028 1046 "pykotaPrinterName" : pname, 1029 "pykotaDateLimit" : "None", 1030 "pykotaPageCounter" : "0", 1031 "pykotaLifePageCounter" : "0", 1032 "pykotaWarnCount" : "0", 1047 "pykotaSoftLimit" : str(upq.SoftLimit), 1048 "pykotaHardLimit" : str(upq.HardLimit), 1049 "pykotaDateLimit" : str(upq.DateLimit), 1050 "pykotaPageCounter" : str(upq.PageCounter or 0), 1051 "pykotaLifePageCounter" : str(upq.LifePageCounter or 0), 1052 "pykotaWarnCount" : str(upq.WarnCount or 0), 1053 "pykotaMaxJobSize" : str(upq.MaxJobSize or 0), 1033 1054 } 1034 1055 if self.info["userquotabase"].lower() == "user" : 1035 dn = "cn=%s,%s" % (uuid, u ser.ident)1056 dn = "cn=%s,%s" % (uuid, upq.User.ident) 1036 1057 else : 1037 1058 dn = "cn=%s,%s" % (uuid, self.info["userquotabase"]) 1038 1059 self.doAdd(dn, fields) 1039 return self.getUserPQuota(user, printer) 1040 1041 def addGroupPQuota(self, group, printer) : 1060 upq.isDirty = False 1061 return None # the entry created doesn't need further modification 1062 1063 def addGroupPQuota(self, gpq) : 1042 1064 """Initializes a group print quota on a printer.""" 1065 oldentry = self.getGroupPQuota(gpq.Group, gpq.Printer) 1066 if oldentry.Exists : 1067 return oldentry # we return the existing entry 1043 1068 uuid = self.genUUID() 1044 gname = self.userCharsetToDatabase(g roup.Name)1045 pname = self.userCharsetToDatabase( printer.Name)1069 gname = self.userCharsetToDatabase(gpq.Group.Name) 1070 pname = self.userCharsetToDatabase(gpq.Printer.Name) 1046 1071 fields = { "cn" : uuid, 1047 1072 "objectClass" : ["pykotaObject", "pykotaGroupPQuota"], … … 1051 1076 } 1052 1077 if self.info["groupquotabase"].lower() == "group" : 1053 dn = "cn=%s,%s" % (uuid, g roup.ident)1078 dn = "cn=%s,%s" % (uuid, gpq.Group.ident) 1054 1079 else : 1055 1080 dn = "cn=%s,%s" % (uuid, self.info["groupquotabase"]) 1056 1081 self.doAdd(dn, fields) 1057 return self.getGroupPQuota(group, printer) 1082 gpq.isDirty = False 1083 return None # the entry created doesn't need further modification 1058 1084 1059 1085 def savePrinter(self, printer) : … … 1204 1230 "pykotaHardLimit" : str(userpquota.HardLimit), 1205 1231 "pykotaDateLimit" : str(userpquota.DateLimit), 1206 "pykotaWarnCount" : str(userpquota.WarnCount), 1207 "pykotaPageCounter" : str(userpquota.PageCounter), 1208 "pykotaLifePageCounter" : str(userpquota.LifePageCounter), 1232 "pykotaWarnCount" : str(userpquota.WarnCount or 0), 1233 "pykotaPageCounter" : str(userpquota.PageCounter or 0), 1234 "pykotaLifePageCounter" : str(userpquota.LifePageCounter or 0), 1235 "pykotaMaxJobSize" : str(userpquota.MaxJobSize or 0), 1209 1236 } 1210 1237 self.doModify(userpquota.ident, fields) … … 1230 1257 "pykotaHardLimit" : str(grouppquota.HardLimit), 1231 1258 "pykotaDateLimit" : str(grouppquota.DateLimit), 1259 "pykotaMaxJobSize" : str(userpquota.MaxJobSize or 0), 1232 1260 } 1233 1261 self.doModify(grouppquota.ident, fields) … … 1427 1455 self.doDelete(group.ident) 1428 1456 1457 def deleteManyUserPQuotas(self, printers, users) : 1458 """Deletes many user print quota entries.""" 1459 # TODO : grab all with a single (possibly VERY huge) filter if possible (might depend on the LDAP server !) 1460 for printer in printers : 1461 for user in users : 1462 upq = self.getUserPQuota(user, printer) 1463 if upq.Exists : 1464 upq.delete() 1465 1466 def deleteManyGroupPQuotas(self, printers, groups) : 1467 """Deletes many group print quota entries.""" 1468 # TODO : grab all with a single (possibly VERY huge) filter if possible (might depend on the LDAP server !) 1469 for printer in printers : 1470 for group in groups : 1471 gpq = self.getGroupPQuota(group, printer) 1472 if gpq.Exists : 1473 gpq.delete() 1474 1429 1475 def deleteUserPQuota(self, upquota) : 1430 1476 """Completely deletes an user print quota entry from the database.""" -
pykota/trunk/pykota/storages/sql.py
r2743 r2749 644 644 (self.doQuote(group.ident), self.doQuote(user.ident))) 645 645 646 def addUserPQuota(self, u ser, printer) :646 def addUserPQuota(self, upq) : 647 647 """Initializes a user print quota on a printer.""" 648 self.doModify("INSERT INTO userpquota (userid, printerid) VALUES (%s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident))) 649 return self.getUserPQuota(user, printer) 650 651 def addGroupPQuota(self, group, printer) : 648 try : 649 self.doModify("INSERT INTO userpquota (userid, printerid, softlimit, hardlimit, warncount, datelimit, pagecounter, lifepagecounter, maxjobsize) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)" \ 650 % (self.doQuote(upq.User.ident), \ 651 self.doQuote(upq.Printer.ident), \ 652 self.doQuote(upq.SoftLimit), \ 653 self.doQuote(upq.HardLimit), \ 654 self.doQuote(upq.WarnCount), \ 655 self.doQuote(upq.DateLimit), \ 656 self.doQuote(upq.PageCounter), \ 657 self.doQuote(upq.LifePageCounter), \ 658 self.doQuote(upq.MaxJobSize))) 659 except PyKotaStorageError : 660 # TODO : check if this is an error different from a duplicate insert 661 # return the existing entry which has to be modified 662 return self.getUserPQuota(upq.User, upq.Printer) 663 else : 664 upq.isDirty = False 665 return None # the entry created doesn't need further modification 666 667 def addGroupPQuota(self, gpq) : 652 668 """Initializes a group print quota on a printer.""" 653 self.doModify("INSERT INTO grouppquota (groupid, printerid) VALUES (%s, %s)" % (self.doQuote(group.ident), self.doQuote(printer.ident))) 654 return self.getGroupPQuota(group, printer) 669 try : 670 self.doModify("INSERT INTO grouppquota (groupid, printerid, softlimit, hardlimit, datelimit, maxjobsize) VALUES (%s, %s, %s, %s, %s, %s)" \ 671 % (self.doQuote(gpq.Group.ident), \ 672 self.doQuote(gpq.Printer.ident), \ 673 self.doQuote(gpq.SoftLimit), \ 674 self.doQuote(gpq.HardLimit), \ 675 self.doQuote(gpq.DateLimit), \ 676 self.doQuote(gpq.MaxJobSize))) 677 except PyKotaStorageError : 678 # TODO : check if this is an error different from a duplicate insert 679 # return the existing entry which has to be modified 680 return self.getGroupPQuota(gpq.Group, gpq.Printer) 681 else : 682 gpq.isDirty = False 683 return None # the entry created doesn't need further modification 655 684 656 685 def savePrinter(self, printer) : … … 738 767 def saveUserPQuota(self, userpquota) : 739 768 """Saves an user print quota entry.""" 740 self.doModify("UPDATE userpquota SET softlimit=%s, hardlimit=%s, warncount=%s, datelimit=%s, pagecounter=%s, lifepagecounter=%s WHERE id=%s" \769 self.doModify("UPDATE userpquota SET softlimit=%s, hardlimit=%s, warncount=%s, datelimit=%s, pagecounter=%s, lifepagecounter=%s, maxjobsize=%s WHERE id=%s" \ 741 770 % (self.doQuote(userpquota.SoftLimit), \ 742 771 self.doQuote(userpquota.HardLimit), \ … … 745 774 self.doQuote(userpquota.PageCounter), \ 746 775 self.doQuote(userpquota.LifePageCounter), \ 776 self.doQuote(userpquota.MaxJobSize), \ 747 777 self.doQuote(userpquota.ident))) 748 778 … … 843 873 self.doModify(q) 844 874 875 def deleteManyUserPQuotas(self, printers, users) : 876 """Deletes many user print quota entries.""" 877 printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 878 userids = ", ".join(["%s" % self.doQuote(u.ident) for u in users]) 879 for q in [ 880 "DELETE FROM jobhistory WHERE userid IN (%s) AND printerid IN (%s)" \ 881 % (userids, printerids), 882 "DELETE FROM userpquota WHERE userid IN (%s) AND printerid IN (%s)" \ 883 % (userids, printerids), 884 ] : 885 self.doModify(q) 886 887 def deleteManyGroupPQuotas(self, printers, groups) : 888 """Deletes many group print quota entries.""" 889 printerids = ", ".join(["%s" % self.doQuote(p.ident) for p in printers]) 890 groupids = ", ".join(["%s" % self.doQuote(g.ident) for g in groups]) 891 for q in [ 892 "DELETE FROM grouppquota WHERE groupid IN (%s) AND printerid IN (%s)" \ 893 % (groupids, printerids), 894 ] : 895 self.doModify(q) 896 845 897 def deleteUserPQuota(self, upquota) : 846 898 """Completely deletes an user print quota entry from the database."""