Show
Ignore:
Timestamp:
09/18/05 00:08:28 (19 years ago)
Author:
jerome
Message:

Did some work to prepare the integration of MaxJobSize? and PassThrough?
mode for printers.

Files:
1 modified

Legend:

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

    r2456 r2459  
    415415        """Extracts printer information given its name : returns first matching printer.""" 
    416416        printer = StoragePrinter(self, printername) 
    417         result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 
     417        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" \ 
     418                      % (printername, self.info["printerrdn"], printername), \ 
     419                        ["pykotaPrinterName", "pykotaPricePerPage", \ 
     420                         "pykotaPricePerJob", "pykotaMaxJobSize", \ 
     421                         "pykotaPassThrough", "uniqueMember", "description"], \ 
     422                      base=self.info["printerbase"]) 
    418423        if result : 
    419424            fields = result[0][1]       # take only first matching printer, ignore the rest 
     
    422427            printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 
    423428            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) 
     429            printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 
     430            printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 
     431            if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     432                printer.PassThrough = 1 
     433            else : 
     434                printer.PassThrough = 0 
    424435            printer.uniqueMember = fields.get("uniqueMember", []) 
    425436            printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     
    638649        printers = [] 
    639650        # see comment at the same place in pgstorage.py 
    640         result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 
     651        result = self.doSearch("(&(objectClass=pykotaPrinter)(|%s))" % "".join(["(pykotaPrinterName=%s)(%s=%s)" % (pname, self.info["printerrdn"], pname) for pname in printerpattern.split(",")]), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "pykotaMaxJobSize", "pykotaPassThrough", "uniqueMember", "description"], base=self.info["printerbase"]) 
    641652        if result : 
    642653            for (printerid, fields) in result : 
     
    646657                printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0] or 0.0) 
    647658                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
     659                printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 
     660                printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 
     661                if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     662                    printer.PassThrough = 1 
     663                else : 
     664                    printer.PassThrough = 0 
    648665                printer.uniqueMember = fields.get("uniqueMember", []) 
    649666                printer.Description = self.databaseToUserCharset(fields.get("description", [""])[0])  
     
    717734                   "pykotaPricePerPage" : "0.0", 
    718735                   "pykotaPricePerJob" : "0.0", 
     736                   "pykotaMaxJobSize" : "0", 
     737                   "pykotaPassThrough" : "0", 
    719738                 }  
    720739        dn = "%s=%s,%s" % (self.info["printerrdn"], printername, self.info["printerbase"]) 
     
    12931312        entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 
    12941313        if entries : 
    1295             result = [ ("dn", "printername", "priceperpage", "priceperjob", "description") ] 
     1314            result = [ ("dn", "printername", "priceperpage", "priceperjob", "description", "maxjobsize", "passthrough") ] 
    12961315            for entry in entries : 
    1297                 result.append((entry.ident, entry.Name, entry.PricePerPage, entry.PricePerJob, entry.Description)) 
     1316                if entry.PassThrough in (1, "1", "t", "true", "T", "TRUE", "True") : 
     1317                    passthrough = "t" 
     1318                else :     
     1319                    passthrough = "f" 
     1320                result.append((entry.ident, entry.Name, entry.PricePerPage, entry.PricePerJob, entry.Description, entry.MaxJobSize, passthrough)) 
    12981321            return result  
    12991322