Changeset 1249

Show
Ignore:
Timestamp:
01/06/04 15:24:59 (21 years ago)
Author:
jalet
Message:

Printer groups should be cached now, if caching is enabled.

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r1248 r1249  
    2525     
    2626        - Allows the dot in user and printer names. 
     27         
     28        - Printer groups are now cached too. 
    2729         
    2830    - 1.16alpha20 : 
  • pykota/trunk/pykota/storage.py

    r1240 r1249  
    2222# 
    2323# $Log$ 
     24# Revision 1.30  2004/01/06 14:24:59  jalet 
     25# Printer groups should be cached now, if caching is enabled. 
     26# 
    2427# Revision 1.29  2003/12/27 16:49:25  uid67467 
    2528# Should be ok now. 
     
    423426        return lastjob     
    424427         
     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         
    425436    def getGroupMembers(self, group) :         
    426437        """Returns the group's members list from in-group cache.""" 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r1244 r1249  
    2222# 
    2323# $Log$ 
     24# Revision 1.43  2004/01/06 14:24:59  jalet 
     25# Printer groups should be cached now, if caching is enabled. 
     26# 
    2427# Revision 1.42  2003/12/29 14:12:48  uid67467 
    2528# Tries to workaround possible integrity violations when retrieving printer groups 
     
    499502        return groups         
    500503         
     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         
    501516    def getMatchingPrinters(self, printerpattern) : 
    502517        """Returns the list of all printers for which name matches a certain pattern.""" 
     
    564579        return groupsandquotas 
    565580         
    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 pgroups 
    577          
    578581    def addPrinter(self, printername) :         
    579582        """Adds a printer to the quota storage, returns it.""" 
  • pykota/trunk/pykota/storages/pgstorage.py

    r1244 r1249  
    2222# 
    2323# $Log$ 
     24# Revision 1.27  2004/01/06 14:24:59  jalet 
     25# Printer groups should be cached now, if caching is enabled. 
     26# 
    2427# Revision 1.26  2003/12/29 14:12:48  uid67467 
    2528# Tries to workaround possible integrity violations when retrieving printer groups 
     
    338341                groups.append(self.getGroup(record.get("groupname"))) 
    339342        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 
    340355         
    341356    def getMatchingPrinters(self, printerpattern) : 
     
    398413        return groupsandquotas 
    399414         
    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 violation 
    407                     parentprinter = self.getPrinter(record.get("printername")) 
    408                     if parentprinter.Exists : 
    409                         pgroups.append(parentprinter) 
    410         return pgroups 
    411          
    412415    def addPrinter(self, printername) :         
    413416        """Adds a printer to the quota storage, returns it."""