Show
Ignore:
Timestamp:
07/01/04 19:45:49 (20 years ago)
Author:
jalet
Message:

Added code to handle the description field for printers

Files:
1 modified

Legend:

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

    r1534 r1582  
    2222# 
    2323# $Log$ 
     24# Revision 1.71  2004/07/01 17:45:49  jalet 
     25# Added code to handle the description field for printers 
     26# 
    2427# Revision 1.70  2004/06/10 20:50:25  jalet 
    2528# Better log message 
     
    535538        """Extracts printer information given its name : returns first matching printer.""" 
    536539        printer = StoragePrinter(self, printername) 
    537         result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember"], base=self.info["printerbase"]) 
     540        result = self.doSearch("(&(objectClass=pykotaPrinter)(|(pykotaPrinterName=%s)(%s=%s)))" % (printername, self.info["printerrdn"], printername), ["pykotaPrinterName", "pykotaPricePerPage", "pykotaPricePerJob", "uniqueMember", "description"], base=self.info["printerbase"]) 
    538541        if result : 
    539542            fields = result[0][1]       # take only first matching printer, ignore the rest 
     
    543546            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    544547            printer.uniqueMember = fields.get("uniqueMember", []) 
     548            printer.Description = fields.get("description", [""])[0] 
    545549            printer.Exists = 1 
    546550        return printer     
     
    700704        printers = [] 
    701705        # see comment at the same place in pgstorage.py 
    702         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"], base=self.info["printerbase"]) 
     706        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"]) 
    703707        if result : 
    704708            for (printerid, fields) in result : 
     
    709713                printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    710714                printer.uniqueMember = fields.get("uniqueMember", []) 
     715                printer.Description = fields.get("description", [""])[0] 
    711716                printer.Exists = 1 
    712717                printers.append(printer) 
     
    895900                   "pykotaPricePerPage" : str(printer.PricePerPage), 
    896901                   "pykotaPricePerJob" : str(printer.PricePerJob), 
     902                 } 
     903        self.doModify(printer.ident, fields) 
     904         
     905    def writePrinterDescription(self, printer) :     
     906        """Write the printer's description back into the storage.""" 
     907        fields = { 
     908                   "description" : str(printer.Description), 
    897909                 } 
    898910        self.doModify(printer.ident, fields)