Changeset 2447

Show
Ignore:
Timestamp:
09/16/05 09:50:27 (19 years ago)
Author:
jerome
Message:

I went too far in the previous modification designed to save database
queries, the print quota entries for the current user on the printers
groups the current printer is a member of weren't created.
Severity : high

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/autopykota

    r2366 r2447  
    6363            raise PyKotaToolError, "Either the username or the printername is undefined. Fatal Error." 
    6464        else : 
     65            printer = self.storage.getPrinter(printername) 
    6566            user = self.storage.getUser(username) 
    6667            if user.Exists : 
    6768                self.logdebug("User %s already exits." % username)  
    68                 printer = self.storage.getPrinter(printername) 
    6969                if printer.Exists : 
    7070                    userpquota = self.storage.getUserPQuota(user, printer) 
    7171                    if userpquota.Exists : 
     72                        # we should never get there, unless autopykota was launched manually 
    7273                        self.logdebug("User %s's quota entry on printer %s already exists. Nothing to do." % (username, printername)) 
    7374                        return 0 
    7475                    else :     
    75                         self.logdebug("Creating a quota entry for user %s on printer %s." % (username, printername)) 
    76                         return os.system('edpykota --add --printer "%s" "%s"' % (printername, username)) 
     76                        printersnames = [printer.Name] + [p.Name for p in self.storage.getParentPrinters(printer)] 
     77                        self.logdebug("Creating a quota entry for user %s on printers %s" % (username, printersnames)) 
     78                        return os.system('edpykota --add --printer "%s" "%s"' % (','.join(printersnames), username)) 
    7779                else : 
    7880                    self.logdebug("Printer %s doesn't exist. Creating printer %s and a quota entry for user %s on printer %s." % (printername, printername, username, printername)) 
    7981                    return os.system('edpykota --add --printer "%s" "%s"' % (printername, username)) 
    8082            else : 
     83                if printer.Exists : 
     84                    printersnames = [printer.Name] + [p.Name for p in self.storage.getParentPrinters(printer)] 
     85                else :     
     86                    printersnames = [printer.Name] 
    8187                self.logdebug("User %s doesn't exist yet." % username) 
    82                 self.logdebug("Creating user %s's account with balance %s and quota entries on printer %s." % (username, options["initbalance"], printername)) 
    83                 return os.system('edpykota --add --limitby balance --balance "%s" --printer "%s" "%s"' % (options["initbalance"], printername, username)) 
     88                self.logdebug("Creating user %s's account with balance %s and quota entries on printers %s" % (username, options["initbalance"], printersnames)) 
     89                return os.system('edpykota --add --limitby balance --balance "%s" --printer "%s" "%s"' % (options["initbalance"], ','.join(printersnames), username)) 
    8490     
    8591if __name__ == "__main__" :     
  • pykota/trunk/NEWS

    r2436 r2447  
    2222PyKota NEWS : 
    2323        
     24    - 1.23alpha29 : 
     25     
     26        - Now autopykota also creates print quota entries for the user on the 
     27          printers groups the current printer is a member of. 
     28           
    2429    - 1.23alpha28 : 
    2530     
  • pykota/trunk/pykota/version.py

    r2435 r2447  
    2222# 
    2323 
    24 __version__ = "1.23alpha28_unofficial" 
     24__version__ = "1.23alpha29_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."