Changeset 2765 for pykota/trunk/pykota/storages/ldapstorage.py
- Timestamp:
- 03/01/06 00:07:05 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r2763 r2765 1462 1462 self.doDelete(group.ident) 1463 1463 1464 def deleteManyBillingCodes FromNames(self, billingcodes) :1465 """Deletes many billing codes from their names."""1466 for bcode in self.getMatchingBillingCodes(",".join(billingcodes)):1464 def deleteManyBillingCodes(self, billingcodes) : 1465 """Deletes many billing codes.""" 1466 for bcode in billingcodes : 1467 1467 bcode.delete() 1468 1468 1469 def deleteManyUsers FromNames(self, usernames) :1470 """Deletes many users from their names."""1471 for user in self.getMatchingUsers(",".join(usernames)) :1469 def deleteManyUsers(self, users) : 1470 """Deletes many users.""" 1471 for user in users : 1472 1472 user.delete() 1473 1473 1474 def deleteManyGroups FromNames(self, groupnames) :1475 """Deletes many groups from their names."""1476 for group in self.getMatchingGroups(",".join(groupnames)) :1474 def deleteManyGroups(self, groups) : 1475 """Deletes many groups.""" 1476 for group in groups : 1477 1477 group.delete() 1478 1478 1479 def deleteManyPrinters FromNames(self, printernames) :1480 """Deletes many printers from their names."""1481 for printer in self.getMatchingPrinters(",".join(printernames)):1479 def deleteManyPrinters(self, printers) : 1480 """Deletes many printers.""" 1481 for printer in printers : 1482 1482 printer.delete() 1483 1483 … … 1701 1701 return code 1702 1702 1703 def addBillingCode(self, label) :1703 def addBillingCode(self, bcode) : 1704 1704 """Adds a billing code to the quota storage, returns it.""" 1705 oldentry = self.getBillingCode(bcode.BillingCode) 1706 if oldentry.Exists : 1707 return oldentry # we return the existing entry 1705 1708 uuid = self.genUUID() 1706 1709 dn = "cn=%s,%s" % (uuid, self.info["billingcodebase"]) 1707 1710 fields = { "objectClass" : ["pykotaObject", "pykotaBilling"], 1708 1711 "cn" : uuid, 1709 "pykotaBillingCode" : self.userCharsetToDatabase(label), 1710 "pykotaPageCounter" : "0", 1711 "pykotaBalance" : "0.0", 1712 "pykotaBillingCode" : self.userCharsetToDatabase(bcode.BillingCode), 1713 "pykotaPageCounter" : str(bcode.PageCounter or 0), 1714 "pykotaBalance" : str(bcode.Balance or 0.0), 1715 "description" : self.userCharsetToDatabase(bcode.Description or ""), 1712 1716 } 1713 1717 self.doAdd(dn, fields) 1714 return self.getBillingCode(label) 1715 1716 def saveBillingCode(self, code) : 1718 bcode.isDirty = False 1719 return None # the entry created doesn't need further modification 1720 1721 def saveBillingCode(self, bcode) : 1717 1722 """Sets the new description for a billing code.""" 1718 1723 fields = { 1719 "description" : self.userCharsetToDatabase( code.Description or ""),1720 "pykotaPageCounter" : str( code.PageCounter),1721 "pykotaBalance" : str( code.Balance),1724 "description" : self.userCharsetToDatabase(bcode.Description or ""), 1725 "pykotaPageCounter" : str(bcode.PageCounter or 0), 1726 "pykotaBalance" : str(bcode.Balance or 0.0), 1722 1727 } 1723 self.doModify( code.ident, fields)1728 self.doModify(bcode.ident, fields) 1724 1729 1725 1730 def getMatchingBillingCodes(self, billingcodepattern) : … … 1744 1749 return codes 1745 1750 1746 def consumeBillingCode(self, code, pagecounter, balance) :1751 def consumeBillingCode(self, bcode, pagecounter, balance) : 1747 1752 """Consumes from a billing code.""" 1748 1753 fields = { … … 1750 1755 "pykotaPageCounter" : { "operator" : "+", "value" : pagecounter, "convert" : int }, 1751 1756 } 1752 return self.doModify( code.ident, fields)1757 return self.doModify(bcode.ident, fields) 1753 1758