Show
Ignore:
Timestamp:
08/18/10 04:20:57 (14 years ago)
Author:
jerome
Message:

Removed support for the MaxJobSize? attribute for users group print quota
entries : I couldn't see a real use for this at the moment, and it would
complexify the code. This support might reappear later however. Added full
support for the MaxJobSize? attribute for user print quota entries,
editable with edpykota's new --maxjobsize command line switch. Changed
the internal handling of the MaxJobSize? attribute for printers :
internally 0 used to mean unlimited, it now allows one to forbid
printing onto a particular printer. The database upgrade script (only
for PostgreSQL) takes care of this.
IMPORTANT : the database schema changes. A database upgrade script is
provided for PostgreSQL only. The LDAP schema doesn't change to not
break any existing LDAP directory, so the pykotaMaxJobSize attribute is
still allowed on group print quota entries, but never used.
Seems to work as expected, for a change :-)
Fixes #15.

Files:
1 modified

Legend:

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

    r3532 r3549  
    447447            printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0]) 
    448448            printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0]) 
    449             printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 
     449            printer.MaxJobSize = fields.get("pykotaMaxJobSize") 
     450            if printer.MaxJobSize is not None : 
     451                if printer.MaxJobSize[0].upper() == "NONE" : 
     452                    printer.MaxJobSize = None 
     453                else : 
     454                    printer.MaxJobSize = int(printer.MaxJobSize[0]) 
    450455            printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 
    451456            if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     
    513518            result = self.doSearch("(&(objectClass=pykotaGroupPQuota)(pykotaGroupName=%s)(pykotaPrinterName=%s))" % \ 
    514519                                      (unicodeToDatabase(group.Name), unicodeToDatabase(printer.Name)), \ 
    515                                       ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit", "pykotaMaxJobSize"], \ 
     520                                      ["pykotaSoftLimit", "pykotaHardLimit", "pykotaDateLimit"], \ 
    516521                                      base=base) 
    517522            if result : 
     
    536541                    else : 
    537542                        grouppquota.DateLimit = grouppquota.DateLimit[0] 
    538                 grouppquota.MaxJobSize = fields.get("pykotaMaxJobSize") 
    539                 if grouppquota.MaxJobSize is not None : 
    540                     if grouppquota.MaxJobSize[0].upper() == "NONE" : 
    541                         grouppquota.MaxJobSize = None 
    542                     else : 
    543                         grouppquota.MaxJobSize = int(grouppquota.MaxJobSize[0]) 
    544543                grouppquota.PageCounter = 0 
    545544                grouppquota.LifePageCounter = 0 
     
    712711                    printer.PricePerJob = float(fields.get("pykotaPricePerJob", [0.0])[0] or 0.0) 
    713712                    printer.PricePerPage = float(fields.get("pykotaPricePerPage", [0.0])[0] or 0.0) 
    714                     printer.MaxJobSize = int(fields.get("pykotaMaxJobSize", [0])[0]) 
     713                    printer.MaxJobSize = fields.get("pykotaMaxJobSize") 
     714                    if printer.MaxJobSize is not None : 
     715                        if printer.MaxJobSize[0].upper() == "NONE" : 
     716                            printer.MaxJobSize = None 
     717                        else : 
     718                            printer.MaxJobSize = int(printer.MaxJobSize[0]) 
    715719                    printer.PassThrough = fields.get("pykotaPassThrough", [None])[0] 
    716720                    if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
     
    892896                   "pykotaPrinterName" : printername, 
    893897                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
    894                    "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
     898                   "pykotaMaxJobSize" : str(printer.MaxJobSize), 
    895899                   "description" : unicodeToDatabase(printer.Description or ""), 
    896900                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
     
    10701074                   "pykotaLifePageCounter" : str(upq.LifePageCounter or 0), 
    10711075                   "pykotaWarnCount" : str(upq.WarnCount or 0), 
    1072                    "pykotaMaxJobSize" : str(upq.MaxJobSize or 0), 
     1076                   "pykotaMaxJobSize" : str(upq.MaxJobSize), 
    10731077                 } 
    10741078        if self.info["userquotabase"].lower() == "user" : 
     
    11061110        fields = { 
    11071111                   "pykotaPassThrough" : (printer.PassThrough and "t") or "f", 
    1108                    "pykotaMaxJobSize" : str(printer.MaxJobSize or 0), 
     1112                   "pykotaMaxJobSize" : str(printer.MaxJobSize), 
    11091113                   "description" : unicodeToDatabase(printer.Description or ""), 
    11101114                   "pykotaPricePerPage" : str(printer.PricePerPage or 0.0), 
     
    12511255                   "pykotaPageCounter" : str(userpquota.PageCounter or 0), 
    12521256                   "pykotaLifePageCounter" : str(userpquota.LifePageCounter or 0), 
    1253                    "pykotaMaxJobSize" : str(userpquota.MaxJobSize or 0), 
     1257                   "pykotaMaxJobSize" : str(userpquota.MaxJobSize), 
    12541258                 } 
    12551259        self.doModify(userpquota.ident, fields) 
     
    12751279                   "pykotaHardLimit" : str(grouppquota.HardLimit), 
    12761280                   "pykotaDateLimit" : str(grouppquota.DateLimit), 
    1277                    "pykotaMaxJobSize" : str(grouppquota.MaxJobSize or 0), 
    12781281                 } 
    12791282        self.doModify(grouppquota.ident, fields) 
     
    16801683        entries = [p for p in [self.getPrinter(name) for name in self.getAllPrintersNames(pname)] if p.Exists] 
    16811684        if entries : 
    1682             fields = ("username", "printername", "dn", "userdn", "printerdn", "lifepagecounter", "pagecounter", "softlimit", "hardlimit", "datelimit") 
     1685            fields = ("username", "printername", "dn", "userdn", "printerdn", "lifepagecounter", "pagecounter", "softlimit", "hardlimit", "datelimit", "maxjobsize") 
    16831686            result = [] 
    16841687            uname = extractonly.get("username") 
    16851688            for entry in entries : 
    16861689                for (user, userpquota) in self.getPrinterUsersAndQuotas(entry, names=[uname or "*"]) : 
    1687                     result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit)) 
     1690                    result.append((user.Name, entry.Name, userpquota.ident, user.ident, entry.ident, userpquota.LifePageCounter, userpquota.PageCounter, userpquota.SoftLimit, userpquota.HardLimit, userpquota.DateLimit, userpquota.MaxJobSize)) 
    16881691            return [fields] + self.sortRecords(fields, result, ["+userdn"], ordering) 
    16891692