Changeset 2756

Show
Ignore:
Timestamp:
02/24/06 11:57:55 (19 years ago)
Author:
jerome
Message:

Removed unneeded stuff.

Location:
pykota/trunk/pykota/storages
Files:
2 modified

Legend:

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

    r2754 r2756  
    866866        return usersandquotas 
    867867                 
    868     def getPrintersUsersAndPQuotas(self, pnames = ["*"], unames=["*"]) :     
    869         """Returns all printers, users and users print quota entries which match a set of names.""" 
    870         printers = {} 
    871         users = {} 
    872         upquotas = {} 
    873         for printer in self.getMatchingPrinters(",".join(pnames)) : 
    874             printers[printer.Name] = printer 
    875         for user in self.getMatchingUsers(",".join(unames)) : 
    876             users[user.Name] = user 
    877         for (p, printer) in printers.items() : 
    878             for (u, user) in users.items() : 
    879                 upqkey = "%s@%s" % (u, p) 
    880                 upquotas[upqkey] = self.getUserPQuota(user, printer) 
    881         return (printers, users, upquotas) 
    882          
    883     def getPrintersGroupsAndPQuotas(self, pnames = ["*"], gnames=["*"]) :     
    884         """Returns all printers, groups and groups print quota entries which match a set of names.""" 
    885         printers = {} 
    886         groups = {} 
    887         gpquotas = {} 
    888         for printer in self.getMatchingPrinters(",".join(pnames)) : 
    889             printers[printer.Name] = printer 
    890         for group in self.getMatchingGroups(",".join(gnames)) : 
    891             groups[group.Name] = group 
    892         for (p, printer) in printers.items() : 
    893             for (g, group) in groups.items() : 
    894                 gpqkey = "%s@%s" % (g, p) 
    895                 gpquotas[gpqkey] = self.getGroupPQuota(group, printer) 
    896         return (printers, groups, gpquotas) 
    897          
    898868    def getPrinterGroupsAndQuotas(self, printer, names=["*"]) :         
    899869        """Returns the list of groups which uses a given printer, along with their quotas.""" 
  • pykota/trunk/pykota/storages/sql.py

    r2754 r2756  
    483483        return codes         
    484484         
    485     def getPrintersUsersAndPQuotas(self, pnames = ["*"], unames=["*"]) :     
    486         """Returns all printers, users and users print quota entries which match a set of names.""" 
    487         matchunames = {} 
    488         matchpnames = {} 
    489         printers = {} 
    490         users = {} 
    491         upquotas = {} 
    492         result = self.doSearch("SELECT users.id AS uid, users.description AS udesc, printers.id AS pid, printers.description AS pdesc, printers.maxjobsize AS pmaxjobsize, userpquota.id AS upqid, userpquota.maxjobsize AS upqmaxjobsize, users.*, printers.*, userpquota.* FROM users, printers, userpquota WHERE users.id=userpquota.userid AND printers.id=userpquota.printerid;") 
    493         if result : 
    494             for record in result : 
    495                 uname = self.databaseToUserCharset(record.get("username")) 
    496                 pname = self.databaseToUserCharset(record.get("printername")) 
    497                 if not matchpnames.has_key(pname) : 
    498                     matchpnames[pname] = printermatches = self.tool.matchString(pname, pnames) 
    499                 else :     
    500                     printermatches = matchpnames[pname] 
    501                 if printermatches :     
    502                     if not matchunames.has_key(uname) : 
    503                         matchunames[uname] = usermatches = self.tool.matchString(uname, unames) 
    504                     else :     
    505                         usermatches = matchunames[uname] 
    506                     if usermatches :     
    507                         printer = StoragePrinter(self, pname) 
    508                         printer.ident = record.get("pid") 
    509                         printer.PricePerJob = record.get("priceperjob") or 0.0 
    510                         printer.PricePerPage = record.get("priceperpage") or 0.0 
    511                         printer.Description = self.databaseToUserCharset(record.get("pdesc") or "")  
    512                         printer.MaxJobSize = record.get("pmaxjobsize") or 0 
    513                         printer.PassThrough = record.get("passthrough") or 0 
    514                         if printer.PassThrough in (1, "1", "t", "true", "TRUE", "True") : 
    515                             printer.PassThrough = 1 
    516                         else : 
    517                             printer.PassThrough = 0 
    518                         printer.Exists = 1 
    519                         printers[pname] = printer 
    520                         self.cacheEntry("PRINTERS", pname, printer) 
    521                          
    522                         user = StorageUser(self, uname) 
    523                         user.ident = record.get("uid") 
    524                         user.LimitBy = record.get("limitby") or "quota" 
    525                         user.AccountBalance = record.get("balance") 
    526                         user.LifeTimePaid = record.get("lifetimepaid") 
    527                         user.Email = record.get("email")  
    528                         user.OverCharge = record.get("overcharge") 
    529                         user.Description = self.databaseToUserCharset(record.get("udesc")) 
    530                         user.Exists = 1 
    531                         users[uname] = user 
    532                         self.cacheEntry("USERS", uname, user) 
    533                          
    534                         upqkey = "%s@%s" % (uname, pname) 
    535                         userpquota = StorageUserPQuota(self, user, printer) 
    536                         userpquota.ident = record.get("id") 
    537                         userpquota.PageCounter = record.get("pagecounter") 
    538                         userpquota.LifePageCounter = record.get("lifepagecounter") 
    539                         userpquota.SoftLimit = record.get("softlimit") 
    540                         userpquota.HardLimit = record.get("hardlimit") 
    541                         userpquota.DateLimit = record.get("datelimit") 
    542                         userpquota.WarnCount = record.get("warncount") 
    543                         userpquota.Exists = 1 
    544                         upquotas[upqkey] = userpquota 
    545                         self.cacheEntry("USERPQUOTAS", upqkey, userpquota) 
    546         return (printers, users, upquotas) 
    547          
    548     def getPrintersGroupsAndPQuotas(self, pnames = ["*"], gnames=["*"]) :     
    549         """Returns all printers, groups and groups print quota entries which match a set of names.""" 
    550         matchgnames = {} 
    551         matchpnames = {} 
    552         printers = {} 
    553         groups = {} 
    554         gpquotas = {} 
    555         result = self.doSearch("SELECT printername, groupname FROM printers, groups") 
    556         if result : 
    557             for record in result : 
    558                 gname = self.databaseToUserCharset(record.get("groupname")) 
    559                 pname = self.databaseToUserCharset(record.get("printername")) 
    560                 if not matchpnames.has_key(pname) : 
    561                     matchpnames[pname] = printermatches = self.tool.matchString(pname, pnames) 
    562                 else :     
    563                     printermatches = matchpnames[pname] 
    564                 if printermatches :     
    565                     if not matchgnames.has_key(gname) : 
    566                         matchgnames[gname] = groupmatches = self.tool.matchString(gname, gnames) 
    567                     else :     
    568                         groupmatches = matchgnames[gname] 
    569                     if groupmatches :     
    570                         printer = self.getPrinter(pname) 
    571                         printers[pname] = printer 
    572                         group = self.getGroup(gname) 
    573                         groups[gname] = group 
    574                         gpqkey = "%s@%s" % (gname, pname) 
    575                         gpquotas[upqkey] = self.getGroupPQuota(group, printer) 
    576         return (printers, groups, gpquotas) 
    577          
    578485    def getPrinterUsersAndQuotas(self, printer, names=["*"]) :         
    579486        """Returns the list of users who uses a given printer, along with their quotas."""