Changeset 2380

Show
Ignore:
Timestamp:
07/21/05 13:59:45 (19 years ago)
Author:
jerome
Message:

Adding, deleting, or listing billing codes now works with LDAP too (finally !)
Only modifying the counters and balance is not done yet.
Severity : be patient, all should be fine before August 1st :-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2375 r2380  
    3636from mx import DateTime 
    3737 
    38 from pykota.storage import PyKotaStorageError, BaseStorage, StorageObject, StorageUser, StorageGroup, StoragePrinter, StorageJob, StorageLastJob, StorageUserPQuota, StorageGroupPQuota 
     38from pykota.storage import PyKotaStorageError, BaseStorage, StorageObject, \ 
     39                           StorageUser, StorageGroup, StoragePrinter, \ 
     40                           StorageJob, StorageLastJob, StorageUserPQuota, \ 
     41                           StorageGroupPQuota, StorageBillingCode 
    3942 
    4043try : 
     
    14031406            self.doModify(code.ident, fields) 
    14041407             
    1405 # def getMatchingBillingCodes(self, billingcodepattern) : 
    1406 # def writeBillingCodeDescription(self, code) : 
     1408    def getMatchingBillingCodes(self, billingcodepattern) : 
     1409        """Returns the list of all billing codes which match a certain pattern.""" 
     1410        codes = [] 
     1411        result = self.doSearch("(&(objectClass=pykotaBilling)%s)" % "".join(["(pykotaBillingCode=%s)" % self.userCharsetToDatabase(bcode) for bcode in billingcodepattern.split(",")]), \ 
     1412                                ["pykotaBillingCode", "description", "pykotaPageCounter", "pykotaBalance"], \ 
     1413                                base=self.info["billingcodebase"]) 
     1414        if result : 
     1415            for (codeid, fields) in result : 
     1416                codename = self.databaseToUserCharset(fields.get("pykotaBillingCode", [""])[0]) 
     1417                code = StorageBillingCode(self, codename) 
     1418                code.ident = codeid 
     1419                code.BillingCode = codename 
     1420                code.PageCounter = int(fields.get("pykotaPageCounter", [0])[0]) 
     1421                code.Balance = float(fields.get("pykotaBalance", [0.0])[0]) 
     1422                code.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     1423                code.Exists = 1 
     1424                codes.append(code) 
     1425                self.cacheEntry("BILLINGCODES", code.BillingCode, code) 
     1426        return codes         
     1427         
    14071428# def setBillingCodeValues(self, code, newbalance, newpagecounter) :     
    14081429# def consumeBillingCode(self, code, balance, pagecounter) :