- Timestamp:
- 02/12/06 00:05:15 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkbcodes
r2673 r2676 146 146 if options["description"] is not None : 147 147 billingcode.setDescription(options["description"].strip()) 148 billingcode.save() 148 149 percent = 100.0 * float(i) / float(nbtotal) 149 150 self.display("\r%.02f%%" % percent) -
pykota/trunk/pykota/storage.py
r2665 r2676 40 40 self.parent = parent 41 41 self.ident = None 42 self.Exists = 0 42 self.isDirty = False 43 self.Exists = False 43 44 44 45 class StorageUser(StorageObject) : … … 452 453 self.parent.deleteBillingCode(self) 453 454 self.parent.flushEntry("BILLINGCODES", self.BillingCode) 454 self.Exists = 0 455 self.Exists = False 456 self.isDirty = False 455 457 456 458 def reset(self, balance=0.0, pagecounter=0) : 457 459 """Resets the pagecounter and balance for this billing code.""" 458 self.parent.setBillingCodeValues(self, pagecounter, balance) 459 self.Balance = balance 460 self.PageCounter = pagecounter 460 if self.Balance != balance : 461 self.Balance = balance 462 self.isDirty = True 463 if self.PageCounter != pagecounter : 464 self.PageCounter = pagecounter 465 self.isDirty = True 461 466 462 467 def setDescription(self, description=None) : … … 466 471 else : 467 472 self.Description = str(description) 468 self.parent.writeBillingCodeDescription(self) 473 self.isDirty = True 474 475 def save(self) : 476 """Saves the billing code to disk in a single operation.""" 477 if self.isDirty : 478 self.parent.saveBillingCode(self) 479 self.isDirty = False 469 480 470 481 def consume(self, pages, price) : -
pykota/trunk/pykota/storages/ldapstorage.py
r2657 r2676 1615 1615 return self.getBillingCode(label) 1616 1616 1617 def writeBillingCodeDescription(self, code) :1617 def saveBillingCode(self, code) : 1618 1618 """Sets the new description for a billing code.""" 1619 1619 fields = { 1620 1620 "description" : self.userCharsetToDatabase(code.Description or ""), 1621 } 1622 if fields["description"] : 1623 self.doModify(code.ident, fields) 1621 "pykotaPageCounter" : str(code.PageCounter), 1622 "pykotaBalance" : str(code.Balance), 1623 } 1624 self.doModify(code.ident, fields) 1624 1625 1625 1626 def getMatchingBillingCodes(self, billingcodepattern) : … … 1645 1646 return codes 1646 1647 1647 def setBillingCodeValues(self, code, newpagecounter, newbalance) :1648 """Sets the new page counter and balance for a billing code."""1649 fields = {1650 "pykotaPageCounter" : str(newpagecounter),1651 "pykotaBalance" : str(newbalance),1652 }1653 return self.doModify(code.ident, fields)1654 1655 1648 def consumeBillingCode(self, code, pagecounter, balance) : 1656 1649 """Consumes from a billing code.""" -
pykota/trunk/pykota/storages/sql.py
r2665 r2676 592 592 self.doModify("UPDATE userpquota SET pagecounter=%s, lifepagecounter=%s, warncount=0, datelimit=NULL WHERE id=%s" % (self.doQuote(newpagecounter), self.doQuote(newlifepagecounter), self.doQuote(userpquota.ident))) 593 593 594 def writeBillingCodeDescription(self, code) :595 """S ets the new description for a billing code."""596 self.doModify("UPDATE billingcodes SET description=%s WHERE id=%s" % (self.doQuote(self.userCharsetToDatabase(code.Description or "")), self.doQuote(code.ident)))597 598 def setBillingCodeValues(self, code, newpagecounter, newbalance) :599 """Sets the new page counter and balance for a billing code."""600 self.doModify("UPDATE billingcodes SET balance=%s, pagecounter=%s WHERE id=%s" % (self.doQuote(newbalance), self.doQuote(newpagecounter),self.doQuote(code.ident)))594 def saveBillingCode(self, code) : 595 """Saves the billing code to the database.""" 596 self.doModify("UPDATE billingcodes SET balance=%s, pagecounter=%s, description=%s WHERE id=%s" \ 597 % (self.doQuote(code.Balance), \ 598 self.doQuote(code.PageCounter), \ 599 self.doQuote(self.userCharsetToDatabase(code.Description)), \ 600 self.doQuote(code.ident))) 601 601 602 602 def consumeBillingCode(self, code, pagecounter, balance) :