Changeset 832 for pykota/trunk/bin

Show
Ignore:
Timestamp:
03/07/03 23:16:57 (22 years ago)
Author:
jalet
Message:

Algorithmically incorrect : last user quota wasn't updated if current
user wasn't allowed to print.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykota

    r826 r832  
    1717# 
    1818# $Log$ 
     19# Revision 1.14  2003/03/07 22:16:57  jalet 
     20# Algorithmically incorrect : last user quota wasn't updated if current 
     21# user wasn't allowed to print. 
     22# 
    1923# Revision 1.13  2003/02/27 23:59:28  jalet 
    2024# Stupid bug wrt exception handlingand value conversion 
     
    148152        # Update the last page counter and last username in the Quota Storage backend 
    149153        # set them to current user and  
    150         kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob) # TODO : allow or deny users not in quota system, and die cleanly if needed 
     154        kotafilter.storage.updatePrinterPageCounter(kotafilter.printername, username, counterbeforejob) 
    151155         
     156        # Was the printer ever used ? 
     157        if (lastpagecounter is None) or (lastusername is None) : 
     158            lastusername = username 
     159            lastpagecounter = counterbeforejob 
     160             
     161        # Update the quota for the previous user on this printer according  
     162        # to the job size (difference between actual counter and latest one from storage) 
     163        jobsize = (counterbeforejob - lastpagecounter)     
     164        if jobsize >= 0 : 
     165            kotafilter.storage.updateUserPQuota(lastusername, kotafilter.printername, jobsize) 
     166            kotafilter.warnUserPQuota(lastusername) 
     167        else :     
     168            kotafilter.logger.log_message(_("Error in page count value %i for user %s on printer %s") % (jobsize, kotafilter.printername, lastusername), "error") 
     169             
    152170        # Is the current user allowed to print at all ? 
     171        # if no then die, else proceed. 
    153172        action = kotafilter.warnUserPQuota(username) 
    154173        if action == "DENY" : 
    155174            # No, just die cleanly 
    156175            return 1 
    157              
    158         # Yes      
    159         if (lastpagecounter is None) or (lastusername is None) : 
    160             lastusername = username 
    161             lastpagecounter = counterbeforejob 
    162         jobsize = (counterbeforejob - lastpagecounter)     
    163         if jobsize >= 0: 
    164             kotafilter.storage.updateUserPQuota(lastusername, kotafilter.printername, jobsize) 
    165             kotafilter.warnUserPQuota(lastusername) 
    166         else :     
    167             kotafilter.logger.log_message(_("Error in page count value %i for user %s on printer %s") % (jobsize, kotafilter.printername, lastusername), "error") 
    168176         
    169177    # pass the job untouched to the underlying layer