Show
Ignore:
Timestamp:
01/10/04 10:44:02 (20 years ago)
Author:
jalet
Message:

Fixed potential accuracy problem if a user printed on several printers at
the very same time.

Files:
1 modified

Legend:

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

    r1259 r1269  
    2222# 
    2323# $Log$ 
     24# Revision 1.36  2004/01/10 09:44:02  jalet 
     25# Fixed potential accuracy problem if a user printed on several printers at 
     26# the very same time. 
     27# 
    2428# Revision 1.35  2004/01/08 16:33:27  jalet 
    2529# Additionnal check to not create a circular printers group. 
     
    171175    def consumeAccountBalance(self, amount) :      
    172176        """Consumes an amount of money from the user's account balance.""" 
    173         newbalance = float(self.AccountBalance or 0.0) - amount 
    174         self.parent.writeUserAccountBalance(self, newbalance) 
    175         self.AccountBalance = newbalance 
     177        self.parent.decreaseUserAccountBalance(self, amount) 
     178        self.AccountBalance = float(self.AccountBalance or 0.0) - amount 
    176179         
    177180    def setAccountBalance(self, balance, lifetimepaid) :     
     
    250253        if (printer not in self.parent.getParentPrinters(self)) and (printer.ident != self.ident) : 
    251254            self.parent.writePrinterToGroup(self, printer) 
     255            # TODO : reset cached value for printer parents, or add new parent to cached value 
    252256         
    253257    def setPrices(self, priceperpage = None, priceperjob = None) :     
     
    301305                self.User.consumeAccountBalance(jobprice) 
    302306                for upq in [ self ] + self.ParentPrintersUserPQuota : 
    303                     newpagecounter = int(upq.PageCounter or 0) + nbpages 
    304                     newlifepagecounter = int(upq.LifePageCounter or 0) + nbpages 
    305                     self.parent.writeUserPQuotaPagesCounters(upq, newpagecounter, newlifepagecounter) 
    306                     upq.PageCounter = newpagecounter 
    307                     upq.LifePageCounter = newlifepagecounter 
     307                    self.parent.increaseUserPQuotaPagesCounters(upq, nbpages) 
     308                    upq.PageCounter = int(upq.PageCounter or 0) + nbpages 
     309                    upq.LifePageCounter = int(upq.LifePageCounter or 0) + nbpages 
    308310        except PyKotaStorageError, msg :     
    309311            self.parent.rollbackTransaction()