Show
Ignore:
Timestamp:
06/16/03 23:55:15 (21 years ago)
Author:
jalet
Message:

More work on LDAP, again. Problem detected.

Files:
1 modified

Legend:

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

    r1031 r1032  
    2121# 
    2222# $Log$ 
     23# Revision 1.10  2003/06/16 21:55:15  jalet 
     24# More work on LDAP, again. Problem detected. 
     25# 
    2326# Revision 1.9  2003/06/16 11:59:09  jalet 
    2427# More work on LDAP 
     
    242245            if result : 
    243246                return [v[self.info["grouprdn"]][0] for (k, v) in result] 
     247        return []         
    244248         
    245249    def addPrinter(self, printername) :         
     
    353357        if result : 
    354358            groupname = result[0][1]["pykotaGroupName"][0] 
    355             members = self.getGroupMembersNames(groupname) 
     359            members = self.getGroupMembersNames(groupname) or [] 
    356360            balance = lifetimepaid = 0.0 
    357361            for member in members : 
     
    417421                   "pykotaSoftLimit" : str(softlimit), 
    418422                   "pykotaHardLimit" : str(hardlimit), 
     423                   "pykotaDateLimit" : "None", 
    419424                 }  
    420425        return self.doModify(userquotaid, fields) 
     
    425430                   "pykotaSoftLimit" : str(softlimit), 
    426431                   "pykotaHardLimit" : str(hardlimit), 
     432                   "pykotaDateLimit" : "None", 
    427433                 }  
    428434        return self.doModify(groupquotaid, fields) 
     
    486492                      "datelimit" : datelimit 
    487493                    } 
    488             members = self.getGroupMembersNames(groupname) 
     494            members = self.getGroupMembersNames(groupname) or [] 
    489495            pagecounter = lifepagecounter = 0 
    490496            printerusers = self.getPrinterUsers(printerid) 
     
    513519        return self.doModify(groupquotaid, fields) 
    514520         
    515     def addJobToHistory(self, jobid, userid, printerid, pagecounter, action) : 
     521    def addJobToHistory(self, jobid, userid, printerid, pagecounter, action, jobsize=None) : 
    516522        """Adds a job to the history: (jobid, userid, printerid, last page counter taken from requester).""" 
    517         raise PyKotaStorageError, "Not implemented !" 
     523        uuid = self.genUUID() 
     524        printername = self.getPrinterName(printerid) 
     525        fields = { 
     526                   "objectClass" : ["pykotaObject", "pykotaJob"], 
     527                   "cn" : uuid, 
     528                   "pykotaUserName" : self.getUserName(userid), 
     529                   "pykotaPrinterName" : printername, 
     530                   "pykotaJobId" : jobid, 
     531                   "pykotaPrinterPageCounter" : str(pagecounter), 
     532                   "pykotaAction" : action, 
     533                 } 
     534        if jobsize is not None :          
     535            fields.update({ "pykotaJobSize" : str(jobsize) }) 
     536        dn = "cn=%s,%s" % (uuid, self.info["jobbase"]) 
     537        self.doAdd(dn, fields) 
     538        result = self.doSearch("(&(objectClass=pykotaLastJob)(pykotaPrinterName=%s))" % printername, None, base=self.info["lastjobbase"]) 
     539        if result : 
     540            lastjdn = result[0][0]  
     541            fields = { 
     542                       "pykotaLastJobIdent" : uuid, 
     543                     } 
     544            self.doModify(lastjdn, fields)          
     545        else :     
     546            lastjuuid = self.genUUID() 
     547            lastjdn = "cn=%s,%s" % (lasjuuid, self.info["lastjobbase"]) 
     548            fields = { 
     549                       "objectClass" : ["pykotaObject", "pykotaLastJob"], 
     550                       "cn" : lastjuuid, 
     551                       "pykotaPrinterName" : printername, 
     552                       "pykotaLastJobIdent" : uuid, 
     553                     }   
     554            self.doAdd(lastjdn, fields)           
    518555     
    519556    def updateJobSizeInHistory(self, historyid, jobsize) : 
    520557        """Updates a job size in the history given the history line's id.""" 
    521         raise PyKotaStorageError, "Not implemented !" 
     558        result = self.doSearch("(&(objectClass=pykotaJob)(cn=%s))" % historyid, ["cn"], base=self.info["jobbase"]) 
     559        if result : 
     560            fields = { 
     561                       "pykotaJobSize" : str(jobsize), 
     562                     } 
     563            self.doModify(result[0][0], fields)          
    522564     
    523565    def getPrinterPageCounter(self, printerid) : 
     
    538580                             "username" : fields.get("pykotaUserName")[0],  
    539581                             "pagecounter" : int(fields.get("pykotaPrinterPageCounter")[0]), 
     582                             "jobsize" : int(fields.get("pykotaJobSize")[0]), 
    540583                           } 
    541584