Changeset 2375
- Timestamp:
- 07/18/05 18:52:19 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/storages/ldapstorage.py
r2373 r2375 846 846 """Write the printer's description back into the storage.""" 847 847 fields = { 848 "description" : self.userCharsetToDatabase(str(printer.Description)), 849 } 850 self.doModify(printer.ident, fields) 848 "description" : self.userCharsetToDatabase(printer.Description or ""), 849 } 850 if fields["description"] : 851 self.doModify(printer.ident, fields) 851 852 852 853 def writeUserOverCharge(self, user, factor) : … … 1369 1370 """Extracts billing code information given its label : returns first matching billing code.""" 1370 1371 code = StorageBillingCode(self, label) 1371 result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % label, ["pykotaBillingCode", "pykotaBalance", "pykotaPageCounter", "description"], base=self.info["billingcodebase"]) 1372 ulabel = self.userCharsetToDatabase(label) 1373 result = self.doSearch("(&(objectClass=pykotaBilling)(pykotaBillingCode=%s))" % ulabel, ["pykotaBillingCode", "pykotaBalance", "pykotaPageCounter", "description"], base=self.info["billingcodebase"]) 1372 1374 if result : 1373 1375 fields = result[0][1] # take only first matching code, ignore the rest 1374 1376 code.ident = result[0][0] 1375 code.BillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [ self.userCharsetToDatabase(label)])[0])1377 code.BillingCode = self.databaseToUserCharset(fields.get("pykotaBillingCode", [ulabel])[0]) 1376 1378 code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 1377 1379 code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) … … 1379 1381 code.Exists = 1 1380 1382 return code 1381 1382 # def getBillingCodeFromBackend(self, label) : 1383 1384 def addBillingCode(self, label) : 1385 """Adds a billing code to the quota storage, returns it.""" 1386 uuid = self.genUUID() 1387 dn = "cn=%s,%s" % (uuid, self.info["billingcodebase"]) 1388 fields = { "objectClass" : ["pykotaObject", "pykotaBilling"], 1389 "cn" : uuid, 1390 "pykotaBillingCode" : self.userCharsetToDatabase(label), 1391 "pykotaPageCounter" : "0", 1392 "pykotaBalance" : "0.0", 1393 } 1394 self.doAdd(dn, fields) 1395 return self.getBillingCode(label) 1396 1397 def writeBillingCodeDescription(self, code) : 1398 """Sets the new description for a billing code.""" 1399 fields = { 1400 "description" : self.userCharsetToDatabase(code.Description or ""), 1401 } 1402 if fields["description"] : 1403 self.doModify(code.ident, fields) 1404 1383 1405 # def getMatchingBillingCodes(self, billingcodepattern) : 1384 # def addBillingCode(self, label) :1385 1406 # def writeBillingCodeDescription(self, code) : 1386 1407 # def setBillingCodeValues(self, code, newbalance, newpagecounter) :