Changeset 2459 for pykota

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.

Location:
pykota/trunk/pykota
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/storage.py

    r2455 r2459  
    150150        self.Description = None 
    151151        self.MaxJobSize = None 
     152        self.PassThrough = None 
    152153        self.Coefficients = None 
    153154         
  • 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         
  • pykota/trunk/pykota/storages/sql.py

    r2455 r2459  
    214214            printer.PricePerJob = fields.get("priceperjob") or 0.0 
    215215            printer.PricePerPage = fields.get("priceperpage") or 0.0 
     216            printer.MaxJobSize = fields.get("maxjobsize") or 0 
     217            printer.PassThrough = fields.get("passthrough") or 0 
     218            if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     219                printer.PassThrough = 1 
     220            else : 
     221                printer.PassThrough = 0 
    216222            printer.Description = self.databaseToUserCharset(fields.get("description") or "") 
    217223            printer.Exists = 1 
     
    352358                    printer.PricePerPage = record.get("priceperpage") or 0.0 
    353359                    printer.Description = self.databaseToUserCharset(record.get("description") or "")  
     360                    printer.MaxJobSize = record.get("maxjobsize") or 0 
     361                    printer.PassThrough = record.get("passthrough") or 0 
     362                    if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     363                        printer.PassThrough = 1 
     364                    else : 
     365                        printer.PassThrough = 0 
    354366                    printer.Exists = 1 
    355367                    printers.append(printer)