Show
Ignore:
Timestamp:
03/01/06 10:47:49 (18 years ago)
Author:
jerome
Message:

Optimized pkprinters like pkbcodes and edpykota.

Files:
1 modified

Legend:

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

    r2765 r2768  
    887887        return groupsandquotas 
    888888         
    889     def addPrinter(self, printername) :         
    890         """Adds a printer to the quota storage, returns it.""" 
    891         printername = self.userCharsetToDatabase(printername) 
     889    def addPrinter(self, printer) : 
     890        """Adds a printer to the quota storage, returns the old value if it already exists.""" 
     891        oldentry = self.getPrinter(printer.Name) 
     892        if oldentry.Exists : 
     893            return oldentry # we return the existing entry 
     894        printername = self.userCharsetToDatabase(printer.Name) 
    892895        fields = { self.info["printerrdn"] : printername, 
    893896                   "objectClass" : ["pykotaObject", "pykotaPrinter"], 
    894897                   "cn" : printername, 
    895898                   "pykotaPrinterName" : printername, 
    896                    "pykotaPricePerPage" : "0.0", 
    897                    "pykotaPricePerJob" : "0.0", 
    898                    "pykotaMaxJobSize" : "0", 
    899                    "pykotaPassThrough" : "0", 
     899                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
     900                   "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
     901                   "description" : self.userCharsetToDatabase(printer.Description or ""), 
     902                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
     903                   "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), 
    900904                 }  
    901905        dn = "%s=%s,%s" % (self.info["printerrdn"], printername, self.info["printerbase"]) 
    902906        self.doAdd(dn, fields) 
    903         return self.getPrinter(printername) 
     907        printer.isDirty = False 
     908        return None # the entry created doesn't need further modification 
    904909         
    905910    def addUser(self, user) :         
     
    10941099        fields = { 
    10951100                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
    1096                    "pykotaMaxJobSize" : (printer.MaxJobSize and str(printer.MaxJobSize)) or "0", 
     1101                   "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
    10971102                   "description" : self.userCharsetToDatabase(printer.Description or ""), 
    1098                    "pykotaPricePerPage" : str(printer.PricePerPage), 
    1099                    "pykotaPricePerJob" : str(printer.PricePerJob), 
     1103                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
     1104                   "pykotaPricePerJob" : str(printer.PricePerJob or 0.0), 
    11001105                 } 
    11011106        self.doModify(printer.ident, fields)