Changeset 1249
- Timestamp:
- 01/06/04 15:24:59 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1248 r1249 25 25 26 26 - Allows the dot in user and printer names. 27 28 - Printer groups are now cached too. 27 29 28 30 - 1.16alpha20 : -
pykota/trunk/pykota/storage.py
r1240 r1249 22 22 # 23 23 # $Log$ 24 # Revision 1.30 2004/01/06 14:24:59 jalet 25 # Printer groups should be cached now, if caching is enabled. 26 # 24 27 # Revision 1.29 2003/12/27 16:49:25 uid67467 25 28 # Should be ok now. … … 423 426 return lastjob 424 427 428 def getParentPrinters(self, printer) : 429 """Extracts parent printers information for a given printer from cache.""" 430 parents = self.getFromCache("PARENTPRINTERS", printer.Name) 431 if parents is None : 432 parents = self.getParentPrintersFromBackend(printer) 433 self.cacheEntry("PARENTPRINTERS", printer.Name, parents) 434 return parents 435 425 436 def getGroupMembers(self, group) : 426 437 """Returns the group's members list from in-group cache.""" -
pykota/trunk/pykota/storages/ldapstorage.py
r1244 r1249 22 22 # 23 23 # $Log$ 24 # Revision 1.43 2004/01/06 14:24:59 jalet 25 # Printer groups should be cached now, if caching is enabled. 26 # 24 27 # Revision 1.42 2003/12/29 14:12:48 uid67467 25 28 # Tries to workaround possible integrity violations when retrieving printer groups … … 499 502 return groups 500 503 504 def getParentPrintersFromBackend(self, printer) : 505 """Get all the printer groups this printer is a member of.""" 506 pgroups = [] 507 result = self.doSearch("(&(objectClass=pykotaPrinter)(uniqueMember=%s))" % printer.ident, ["pykotaPrinterName"], base=self.info["printerbase"]) 508 if result : 509 for (printerid, fields) in result : 510 if printerid != printer.ident : # In case of integrity violation. 511 parentprinter = self.getPrinter(fields.get("pykotaPrinterName")[0]) 512 if parentprinter.Exists : 513 pgroups.append(parentprinter) 514 return pgroups 515 501 516 def getMatchingPrinters(self, printerpattern) : 502 517 """Returns the list of all printers for which name matches a certain pattern.""" … … 564 579 return groupsandquotas 565 580 566 def getParentPrinters(self, printer) :567 """Get all the printer groups this printer is a member of."""568 pgroups = []569 result = self.doSearch("(&(objectClass=pykotaPrinter)(uniqueMember=%s))" % printer.ident, ["pykotaPrinterName"], base=self.info["printerbase"])570 if result :571 for (printerid, fields) in result :572 if printerid != printer.ident : # In case of integrity violation.573 parentprinter = self.getPrinter(fields.get("pykotaPrinterName")[0])574 if parentprinter.Exists :575 pgroups.append(parentprinter)576 return pgroups577 578 581 def addPrinter(self, printername) : 579 582 """Adds a printer to the quota storage, returns it.""" -
pykota/trunk/pykota/storages/pgstorage.py
r1244 r1249 22 22 # 23 23 # $Log$ 24 # Revision 1.27 2004/01/06 14:24:59 jalet 25 # Printer groups should be cached now, if caching is enabled. 26 # 24 27 # Revision 1.26 2003/12/29 14:12:48 uid67467 25 28 # Tries to workaround possible integrity violations when retrieving printer groups … … 338 341 groups.append(self.getGroup(record.get("groupname"))) 339 342 return groups 343 344 def getParentPrintersFromBackend(self, printer) : 345 """Get all the printer groups this printer is a member of.""" 346 pgroups = [] 347 result = self.doSearch("SELECT groupid,printername FROM printergroupsmembers JOIN printers ON groupid=id WHERE printerid=%s;" % self.doQuote(printer.ident)) 348 if result : 349 for record in result : 350 if record["groupid"] != printer.ident : # in case of integrity violation 351 parentprinter = self.getPrinter(record.get("printername")) 352 if parentprinter.Exists : 353 pgroups.append(parentprinter) 354 return pgroups 340 355 341 356 def getMatchingPrinters(self, printerpattern) : … … 398 413 return groupsandquotas 399 414 400 def getParentPrinters(self, printer) :401 """Get all the printer groups this printer is a member of."""402 pgroups = []403 result = self.doSearch("SELECT groupid,printername FROM printergroupsmembers JOIN printers ON groupid=id WHERE printerid=%s;" % self.doQuote(printer.ident))404 if result :405 for record in result :406 if record["groupid"] != printer.ident : # in case of integrity violation407 parentprinter = self.getPrinter(record.get("printername"))408 if parentprinter.Exists :409 pgroups.append(parentprinter)410 return pgroups411 412 415 def addPrinter(self, printername) : 413 416 """Adds a printer to the quota storage, returns it."""