Changeset 1285 for pykota/trunk/pykota/storage.py
- Timestamp:
- 01/12/04 23:43:40 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storage.py
r1274 r1285 22 22 # 23 23 # $Log$ 24 # Revision 1.38 2004/01/12 22:43:40 jalet 25 # New formula to compute a job's price 26 # 24 27 # Revision 1.37 2004/01/12 14:35:01 jalet 25 28 # Printing history added to CGI script. … … 300 303 self.PageCounter = 0 301 304 302 def increasePagesUsage(self, nbpages) : 305 def computeJobPrice(self, jobsize) : 306 """Computes the job price as the sum of all parent printers' prices + current printer's ones.""" 307 totalprice = 0.0 308 if jobsize : 309 for upq in [ self ] + self.ParentPrintersUserPQuota : 310 price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0) 311 totalprice += price 312 return totalprice 313 314 def increasePagesUsage(self, jobsize) : 303 315 """Increase the value of used pages and money.""" 304 jobprice = (float(self.Printer.PricePerPage or 0.0) * nbpages) + float(self.Printer.PricePerJob or 0.0)305 self.parent.beginTransaction()306 try :307 if nbpages:316 jobprice = self.computeJobPrice(jobsize) 317 if jobsize : 318 self.parent.beginTransaction() 319 try : 308 320 self.User.consumeAccountBalance(jobprice) 309 321 for upq in [ self ] + self.ParentPrintersUserPQuota : 310 self.parent.increaseUserPQuotaPagesCounters(upq, nbpages) 311 upq.PageCounter = int(upq.PageCounter or 0) + nbpages 312 upq.LifePageCounter = int(upq.LifePageCounter or 0) + nbpages 313 except PyKotaStorageError, msg : 314 self.parent.rollbackTransaction() 315 raise PyKotaStorageError, msg 316 else : 317 self.parent.commitTransaction() 322 self.parent.increaseUserPQuotaPagesCounters(upq, jobsize) 323 upq.PageCounter = int(upq.PageCounter or 0) + jobsize 324 upq.LifePageCounter = int(upq.LifePageCounter or 0) + jobsize 325 except PyKotaStorageError, msg : 326 self.parent.rollbackTransaction() 327 raise PyKotaStorageError, msg 328 else : 329 self.parent.commitTransaction() 330 return jobprice 318 331 319 332 class StorageGroupPQuota(StorageObject) : … … 366 379 def setSize(self, jobsize) : 367 380 """Sets the last job's size.""" 368 jobprice = (float(self.Printer.PricePerPage or 0.0) * jobsize) + float(self.Printer.PricePerJob or 0.0)381 jobprice = self.parent.getUserPQuota(self.User, self.Printer).computeJobPrice(jobsize) 369 382 self.parent.writeLastJobSize(self, jobsize, jobprice) 370 383 self.JobSize = jobsize