Show
Ignore:
Timestamp:
06/25/03 16:10:01 (21 years ago)
Author:
jalet
Message:

Hey, it may work (edpykota --reset excepted) !

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/stupid.py

    r1000 r1041  
    2121# 
    2222# $Log$ 
     23# Revision 1.4  2003/06/25 14:10:01  jalet 
     24# Hey, it may work (edpykota --reset excepted) ! 
     25# 
    2326# Revision 1.3  2003/05/27 23:00:21  jalet 
    2427# Big rewrite of external accounting methods. 
     
    3942 
    4043class Accounter(AccounterBase) : 
    41     def doAccounting(self, printerid, userid) : 
     44    def doAccounting(self, printer, user) : 
    4245        """Does print accounting by stupidly counting the 'showpage' postscript instructions in the document. 
    4346         
     
    5154             
    5255        # get last job information for this printer 
    53         pgc = self.filter.storage.getPrinterPageCounter(printerid)     
    54         if pgc is None : 
     56        if not printer.LastJob.Exists : 
    5557            # The printer hasn't been used yet, from PyKota's point of view 
    5658            counterbeforejob = 0 
     
    5961            # Last lifetime page counter before actual job is  
    6062            # last page counter + last job size 
    61             counterbeforejob = (pgc["pagecounter"] or 0) + (pgc["jobsize"] or 0) 
     63            counterbeforejob = int(printer.LastJob.PrinterPageCounter or 0) + int(printer.LastJob.JobSize or 0) 
    6264             
    6365        # Is the current user allowed to print at all ? 
    64         action = self.filter.warnUserPQuota(self.filter.username, self.filter.printername) 
     66        userpquota = self.filter.storage.getUserPQuota(user, printer) 
     67        action = self.filter.warnUserPQuota(userpquota) 
    6568         
    6669        # update the quota for the current user on this printer, if allowed to print 
     
    6871            jobsize = 0 
    6972        else :     
    70             self.filter.storage.updateUserPQuota(userid, printerid, jobsize) 
     73            userpquota.increasePagesUsage(jobsize) 
    7174         
    7275        # adds the current job to history     
    73         self.filter.storage.addJobToHistory(self.filter.jobid, self.filter.storage.getUserId(self.filter.username), printerid, counterbeforejob, action, jobsize) 
     76        printer.addJobToHistory(self.filter.jobid, user, counterbeforejob, action, jobsize) 
    7477             
    7578        return action