Changeset 1252

Show
Ignore:
Timestamp:
01/06/04 17:02:57 (21 years ago)
Author:
jalet
Message:

This time printer groups caching works.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storage.py

    r1250 r1252  
    2222# 
    2323# $Log$ 
     24# Revision 1.32  2004/01/06 16:02:57  jalet 
     25# This time printer groups caching works. 
     26# 
    2427# Revision 1.31  2004/01/06 15:51:24  jalet 
    2528# Fixed caching of printer groups 
     
    353356        if self.usecache : 
    354357            self.tool.logdebug("Caching enabled.") 
    355             self.caches = { "USERS" : {}, "GROUPS" : {}, "PRINTERS" : {}, "USERPQUOTAS" : {}, "GROUPPQUOTAS" : {}, "JOBS" : {}, "LASTJOBS" : {}, "PARENTPRINTERS" : {} } 
     358            self.caches = { "USERS" : {}, "GROUPS" : {}, "PRINTERS" : {}, "USERPQUOTAS" : {}, "GROUPPQUOTAS" : {}, "JOBS" : {}, "LASTJOBS" : {} } 
    356359         
    357360    def close(self) :     
     
    431434    def getParentPrinters(self, printer) :     
    432435        """Extracts parent printers information for a given printer from cache.""" 
    433         parents = self.getFromCache("PARENTPRINTERS", printer.Name) 
    434         if parents is None : 
    435             parents = self.getParentPrintersFromBackend(printer) 
    436             self.cacheEntry("PARENTPRINTERS", printer.Name, parents) 
    437         return parents     
     436        if self.usecache : 
     437            if not hasattr(printer, "Parents") : 
     438                self.tool.logdebug("Cache miss (%s->Parents)" % printer.Name) 
     439                printer.Parents = self.getParentPrintersFromBackend(printer) 
     440                self.tool.logdebug("Cache store (%s->Parents)" % printer.Name) 
     441            else : 
     442                self.tool.logdebug("Cache hit (%s->Parents)" % printer.Name) 
     443        else :         
     444            printer.Parents = self.getParentPrintersFromBackend(printer) 
     445        return printer.Parents 
    438446         
    439447    def getGroupMembers(self, group) :